Martin v. Löwis wrote:
>
> It seems that everybody is proposing libraries that use in-memory
> representations. There is a standard xml package for Python, it's
> called "xml" (and comes with the standard library). It contains a
> SAX interface, xml.sax, which can parse files incrementally.
What about xml.dom.pulldom? It quite possibly resembles ElementTree's
iterparse, or at least promotes event-style handling of XML information
using some kind of mainloop...
import xml.dom.pulldom
for etype, node in xml.dom.pulldom.parseString(s):
if etype == xml.dom.pulldom.START_ELEMENT:
print node.nodeName, node.attributes
...instead of callbacks (as happens with SAX):
import xml.sax
class CH(xml.sax.ContentHandler):
def startElement(self, name, attrs):
print name, attrs
xml.sax.parseString(s, CH())
Paul
--
http://mail.python.org/mailman/listinfo/python-list