xml getElementsByTagName w/o recursion?
Bill Rubenstein
wsr2 at swbell.net
Wed Feb 11 09:04:47 EST 2004
In article <ab4c5633.0402110336.4d786ff6 at posting.google.com>, sdahlbac at abo.fi
says...
> 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
>
You need to loop through the children of the node and build a list of the nodes
of interest.
Bill R
More information about the Python-list
mailing list