Re: incremental parser

"Stefan Behnel" <[email protected]> Wed, 22 Oct 2008 08:08:57 +0200 (CEST)
Newsgroups gmane.comp.python.xml
Message-ID <34739.213.61.181.86.1224655737.squirrel@groupware.dvs.informatik.tu-darmstadt.de>
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.

http://docs.python.org/library/xml.etree.elementtree.html#functions
http://effbot.org/zone/element-iterparse.htm

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.

Stefan

_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig