Keo Sophon wrote:
> On Friday 31 March 2006 17:37, Kent Johnson wrote:
> 
>>Keo Sophon wrote:
>>
>>>How can I get a name of an XML node and and its property name and its
>>>property value?
>>
>>How are your reading the XML? (xml.dom, ElementTree, BeautifulSoup...)
>>
> 
> I am using xml.dom.

I generally use ElementTree for XML access, it is much simpler than 
xml.dom. But here is what I figured out:
The tag name is node.nodeName

If by property you mean attribute, you can get a list of all attributes 
by node.attributes.keys() and access the value of a particular one by
node.attributes['attributeName'].nodeValue

Google python xml.dom to find many more examples. Or Google ElementTree 
to find an easier way to do it...

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to