Re: Where is the xml.dom.ext package in current pythondistributions? .ext documentation?

"Martin v. Löwis" <[email protected]>
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
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
_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.