xml getElementsByTagName w/o recursion?

Simon Dahlbacka sdahlbac at abo.fi
Wed Feb 11 06:36:40 EST 2004


Hello,

this is perhaps not directly a python question, but how do I get a
direct child element without going down the tree and possibly find
another element with the same name there?


<foo>
 <bar>
  <name>This is the interesting part</name>
  <baz>
   <something>...</something>
   <name>this is what I DO NOT want</nameA
  </baz>
 </bar>
</foo>

I am using xml.dom.minidom and I was thinking along the line of

...
fooNode.childNodes.getNamedNode("name")
...
but that doesn't work..

is the only solution to write an own helper function that iterates the
child nodes and get the correct one?

/Simon



More information about the Python-list mailing list