[FRPythoneers] xml difference in 1.5 to 2.1
Andrew R. Diederich
diederic at boulder.net
Wed Aug 22 14:09:02 MDT 2001
Hmm, it does look like minidom does what core did (__doc__ for both says
they're light implementations of DOM, anyway). Now I can't find what
happend to sax_builder. *sigh* I've tried the little I know to find out
what exactly it does, but since I'm just learning all this, the words
don't mean much to me. From 1.5.2:
>>> print xml.dom.sax_builder.__doc__
sax_builder.py: SaxBuilder class implementation.
SaxBuilder builds a DOM-conformant grove from evenements generated by a
Below is the example I'm trying to figure out, and move to 2.1.
# Import the core DOM module
from xml.dom import minidom
# Import the DOM SAX builder
from xml.dom.sax_builder import SaxBuilder
# Import the SAX modules
from xml.sax import saxexts, saxlib
# Print the data content of a node list
for n in nodelist:
if n.nodeType == core.TEXT_NODE:
# For text nodes, data content is available as
# the nodeValue instance varirable.
elif n.nodeType == core.ELEMENT_NODE:
# For element nodes, call PrintText,
# recursively passing it the list
# of children of the current node.
# Create SAX parser
p = saxexts.make_parser()
# Create a SAX document handler which will build the DOM tree
dh = SaxBuilder()
# Tell the parser about the document handler
# Parse the document.
doc = dh.document
On Wed, 22 Aug 2001, Ken Kinder wrote:
> I don't think you should need to use the core object. Here is what my
> XML processing looks like with DOM and it works on both.
> import xml.dom.minidom
> dom = xml.dom.minidom
> rootelement = dom.Element('tag')
> If you're serious about XML, check out 4suite.org -- they have much
> better (IMHO) XML modules, although if you're shipping an application,
> it's a pain to get users to get that stuff installed.
More information about the FRPythoneers