[XML-SIG] Node as Element?

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Thu, 20 Dec 2001 18:08:54 +0100 (CET)


On Thu, 20 Dec 2001, Ian Sparks wrote:

> You were correct (thanks also to Rich and Alexandre).
> 
> Pesky WhiteSpace!
> 
> I think there's a setting for the DOM to filter this out when it is parsed
> into the DOM?

Yes : you can build your dom tree with validation (which means you need a
DTD to validate against), or you can use xml.dom.ext.StripXml(document) to
remove whitespace after parsing. 

You'll also have to take care of Comment nodes, and maybe of
ProcessingInstructions. I don't use the latter, but comments can be a real
pain sometimes. 

You can also use the DOM Traversal API to iterate through the tree. This
API enables you to filter out some nodes, so you'd be able to forget get
only Elements reported during the traversal. 

Finally, you could use XPath, which gives you random access to any point
of the tree, without bothering about iteration.

Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).