minidom, drilling down to a low node in one line?

Matt Brown - nyc MatthewBrown at gmail.com
Fri Jan 16 13:33:03 EST 2009


Hello,


I hope this isn't completely redundant...

I'm working with an example found of parsing XML with xml.dom.minidom
and am having some issues getting a node down three levels.

Here is the tutorial:
http://diveintopython.org/xml_processing/parsing_xml.html

Given the XML:
_____________
<?xml version="1.0" ?>
<grammar>
<ref id="bit">
  <p>0</p>
  <p>1</p>
</ref>
</grammar>
_____________

How do I address the textNode.data that = 0?

The only way I figured out is to recursively childNode from the parsed
down (as following the guide).  Is there no way to simply address the
item by something along the lines of:

_____________
xmldoc = minidom.parse("example.xml")
xmldoc.getElementsByTagName("grammar:ref:p:")
_____________


Any input or direction is appreciated.


Thanks!

Matt



More information about the Python-list mailing list