minidom
Erik Max Francis
max at alcyone.com
Tue Dec 4 01:57:07 EST 2001
Duncan Smith wrote:
> This may be a stupid question, but I'm struggling. I can retreive
> information from an XML file (using minidom) as long as it is a node
> attribute. But I cannot figure out how to get data otherwise. eg.
>
> <VAR NAME="ESLeak" TYPE="discrete" XPOS="16030" YPOS="16030">
>
> <DESCRIPTION>EngineStart Leak</DESCRIPTION>
>
> <STATENAME>good</STATENAME>
>
> <STATENAME>bad</STATENAME>
>
> XPOS etc. no problem. But how (using minidom) do I retreive 'Engine
> Start
> Leak' and 'good' etc? Anyone know of any good documentation / worked
> examples for minidom? Thanks in advance.
If VAR is your root element, then the other element nodes are children
of it. If not and there's a different root element, then all these
element nodes are siblings of it.
Nodes are arranged in a hierarchical structure:
VAR element [with attributes]
DESCRIPTION element
text node ("EngineStart Leak")
STATENAME element
text node ("good")
STATENAME element
text node ("bad")
Traverse the tree by looking at the childNodes attribute (Python
attribute, not XML attribute).
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Laws are silent in time of war.
\__/ Cicero
Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
An Esperanto reference for English speakers.
More information about the Python-list
mailing list