Elementtree tag

Waldemar Osuch waldemar.osuch at gmail.com
Thu Dec 13 23:46:03 EST 2007


On Dec 13, 7:52 pm, Sean DiZazzo <half.ital... at gmail.com> wrote:
> I have a another question...
>
> using elementtree, is there a proper way to get at the data
> '123456789' in this tag?
>
> '<id 123456789 />'
>
> I tried making it an element, but the only attribute that returns
> anything is the "tag" attribute.  Does that section of a tag have any
> proper name that I'm missing?  Or is it just bad XML style?
>
It is not even legal xml.
This may work.

>>> from xml.etree import ElementTree as ET
>>> elm = ET.fromstring('<atag id="123456789" />')
>>> elm
<Element atag at 1ba2f80>
>>> elm.attrib
{'id': '123456789'}
>>>





More information about the Python-list mailing list