List Info

Thread: XML node name and property




XML node name and property
user name
2006-03-31 04:01:18
Hi all,

How can I get a name of an XML node and and its property
name and its property 
value?

Thanks,
Sophon
_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor
XML node name and property
user name
2006-03-31 10:37:47
Keo Sophon wrote:
> Hi all,
> 
> 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...)

Kent

_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor
XML node name and property
user name
2006-03-31 11:17:03
On Friday 31 March 2006 17:37, Kent Johnson wrote:
> Keo Sophon wrote:
> > Hi all,
> >
> > 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...)
>
> Kent
>
> _______________________________________________
> Tutor maillist  -  Tutorpython.org
> http://
mail.python.org/mailman/listinfo/tutor


I am using xml.dom.

Phon
_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor
XML node name and property
user name
2006-03-31 13:13:14
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  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )