Re: [xml] Newline at the end of output



Just a follow up, since there is an XML_SAVE_NO_EMPTY option I tried that but it still prints out even this empty element in the case of xmlSaveDoc.  Seems like it was going to be a better workaround for me but it doesn't work.  I still sometimes need to print out the prolog but xmlSaveTree will not ever add the deceleration.

~James


On Tue, Jun 9, 2009 at 3:30 PM, James Hart <beeblebrox42 gmail com> wrote:
Martin,

  Exactly the answer I needed.  The xmlSaveTree works great.

~James

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:
<https://bugs.webkit.org/show_bug.cgi?id=15919>
<http://bugzilla.gnome.org/show_bug.cgi?id=495668>
<http://trac.webkit.org/changeset/28014>
<http://trac.webkit.org/browser/trunk/WebCore/xml/XSLTProcessor.cpp?rev=42738#L192>

Martin



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



--
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]