Re: [xml] Remove whitespaces from text nodes

spam spam spam spam free fr schrieb am 15.02.2012 um 10:00 (+0100):

But now, I am wondering if there is a solution just using libxml2
(without libxslt).
In fact, I am requesting for a transformation of the XML document.
Indeed, the original node contains whitespaces and I want to remove
So I think the answer is "NO!", because this is the job of stylesheets
to apply this transformation.

Can someone tell me if there is a way to apply a function which does
this work in libxml2 ?

It might help you to think about it in terms of _parser_ and
_application_. The XML parser can be tweaked to parse the doc
using this or that option, like removing non-significant
whitespace-only text nodes, or validating the doc against a DTD.

What you want to do is not part of what the parser can be
_configured_ to do.

What you *could* do is write a SAX handler to do what the XSLT
does. However, SAX is simply low-level and more work than XSLT.
Unless, of course, you know SAX and don't know XSLT.

That's all I can say about it.
Michael Ludwig

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