Does anybody know about something similar to XML::Twig (see
<http://www.xmltwig.com>) for Python?
It lets you work on parts of XML documents as trees, without having to
parse all of it at once like a standard DOM requires. Very nice for
processing really huge docs, but then again, its a perl module ;-)
tia
Henrik
> Does anybody know about something similar to XML::Twig (see
> <http://www.xmltwig.com>) for Python?
from your description, it sounds like the "pulldom" standard
module is what you want:
from xml.dom import pulldom
source = pulldom.parse("somefile.xml")
for event, node in source:
# node is now a dom node without child elements
if event == "START_ELEMENT" and node.tagName == "record":
# make sure we have all child elements
source.expandNode(node)
process(node)
</F>