Re: [xml] Newline at the end of output

On 09/06/2009, James Hart <beeblebrox42 gmail com> wrote:
I have a use case where I need to treat an xml document as a document
fragment, I won't get into the details of why exactly, but lets make the
assumption it is a valid use case for now.

For your case, rather than doing:

  xmlSaveDoc(saveCtxt, doc_);

Instead do:

xmlSaveTree(saveCtxt, xmlDocGetRootElement(doc_));

I don't want to have to hack the removal of this newline in my code if it
can be helped.  Is there a way to do this and not get the newline?  Is there
a way to output the xml string for just the root element instead of using
the document approach to get around this?

Just hacking off the trailing newline is the method that's been used
when needed in the past, see for instance:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]