[XML-SIG] incremental parser

Stefan Behnel stefan_ml at behnel.de
Wed Oct 22 08:08:57 CEST 2008

amit sethi wrote:
> hi , I am new to python as well as xml . I am trying to make a program
> which
> reads an xml document reads the attributes of an element and makes a
> decision as to whether it wants to keep it the new xml file that is being
> created at the same time . Is xml.sax.xmlreader.IncrementalParser good for
> this . Can anybody give me an example as to how to use Incremental parser.

I think what you are looking for is ElementTree's iterparse() function.


Note that this will build a tree (very fast, BTW) and will let you
interact with each element it touches. Once you're done, just serialise
the resulting tree.


More information about the XML-SIG mailing list