Python xml.dom, help reading attribute data
Giovanni Bajo
noway at sorry.com
Tue Sep 6 20:38:20 EDT 2005
Thierry Lam wrote:
> Let's say I have the following xml tag:
>
> <para role="success">1</para>
>
> I can't figure out what kind of python xml.dom codes I should invoke
> to read the data 1? Any help please?
>
> Thanks
> Thierry
If you use elementtree:
>>> from elementtree import ElementTree
>>> node = ElementTree.fromstring("""<para role="success">1</para>""")
>>> node.text
'1'
>>> node.attrib["role"]
'success'
--
Giovanni Bajo
More information about the Python-list
mailing list