Elementtree tag

Sean DiZazzo half.italian at gmail.com
Fri Dec 14 00:46:33 EST 2007


On Dec 13, 8:46 pm, Waldemar Osuch <waldemar.os... at gmail.com> wrote:
> 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'}

Thanks. I was afraid of that. Yet another hack for my code.  argggh



More information about the Python-list mailing list