Re: [xml] Newline at the end of output


  Exactly the answer I needed.  The xmlSaveTree works great.


On Tue, Jun 9, 2009 at 2:56 PM, Martin (gzlist) <gzlist googlemail com> wrote:
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:


If there is anything bigger than my ego around, I want it caught and shot now!

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