[XML-SIG] Re: Removing insignificant whitespace

Fredrik Lundh fredrik at pythonware.com
Wed Sep 1 18:31:48 CEST 2004

Brian Quinlan wrote:

> Yes, but whitespace-only nodes are very common in XML formatted for human consumption e.g.
> <foo>
> <bar>Hello</bar>
> <bar>Hi</bar>
> </foo>
> I count 3 whitespace-only nodes (even after normalize). Those nodes are not useful to the 
> application some I'm wondering about the canonical way of removing them (without writing the 
> [admittedly simple] code myself).

Note that in the elementtree model, most of those disappear into the "tail"
attribute.  No need to write code to skip over whitespace nodes; just get
the "bar" element's "text" attribute and you're done.


More information about the XML-SIG mailing list