[XML-SIG] Where is the xml.dom.ext package in current pythondistributions? .ext documentation?
"Martin v. Löwis"
martin at v.loewis.de
Wed Feb 7 22:06:34 CET 2007
Anastasios Hatzis schrieb:
> Is the xml.dom entirely -with all subpackages/modules- available under
> the same package in Python?
Not at all. Not with all subpackages; primarily, just minidom is
included (and pulldom and the DOM builder).
> # (1) for reading/parsing data from XML:
> from xml.dom.ext.reader import Sax2
Use xml.dom.minidom.parse instead.
> # (2) for building/manipulating DOM tree:
> from xml.dom.DOMImplementation import implementation
Use xml.dom.minidom instead. If you need a DOMImplementation,
use xml.dom.getDOMImplementation(). If you need to create
nodes and such, use the relevant create* factory method on
the document.
> # (3) for serializing data to XML:
> from xml.dom.ext import PrettyPrint
Use toxml/toprettyxml instead.
> in order to get a DOM tree from the XML file which I can than walk
> through - I don't care the events... but I thought SAX is
> event-driven?!? However, I need to switch to a tree-based XML parser
> alternative on Python distribution.
Correct. What you currently uses is called a "DOM builder" (i.e.
an algorithm that creates a DOM tree) out of SAX2 events.
So it consumes SAX events and produces a DOM tree. Python comes
with a different such builder out of the box.
Regards,
Martin
More information about the XML-SIG
mailing list