June 2000
Intermediate to advanced
556 pages
8h 45m
English
The DOM specification purposely says nothing about the creation of the hierarchical data it provides access to. When the source is XML, one good way to load the DOM is through SAX events. In the program below, a SAX parser creates a DOM tree which then re-creates the XML document as output.
CD-ROM reference=11001.txt
C>type dom1.py """ Create a DOM tree structure from an XML file, using a SAX parser. """ # Import the core DOM module. from xml.dom import core # Import the SAX DOM builder. from xml.dom.sax_builder import SaxBuilder # Import the SAX modules. from xml.sax import saxexts,saxlib import sys # Create a SAX parser. p = saxexts.make_parser() # Create a SAX document handler which will build the DOM ...Read now
Unlock full access