[XML-SIG] How to parse an XML in SAX

Stefan Behnel stefan_ml at behnel.de
Sun Nov 11 16:16:13 CET 2007


Alexandro Colorado wrote:
> Hi I want to parse an XML using sax

Any reason why you would want to do that?


> but my big issue are the WhiteSpaces  
> when they get reported. I want to know how to efficiently ignore them. I  
> know there are some DocumentHandlers and one specific for ignore  
> Whitespace but I still come up with a bunch of invisible nodes like \t or  
> \n.
> 
> Anyone have a tutorial on how to handle SAX for this kind of parsing?

Consider using cElementTree's iterparse() instead.

http://effbot.org/zone/element-iterparse.htm

It's also available in lxml.etree.

Stefan


More information about the XML-SIG mailing list