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

M

Matt Brown - nyc

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top