Home

I have a doc with a bunch of fields like:

<foo bar="spam">stuff</foo>
<foo bar="penguin">other stuff</foo>

and sometimes

<foo bar="parrot"></foo>

I use ElementTree to parse the doc and I use the .text attribute
to get "stuff" or "other stuff" in the spam and penguin examples.

I'd expect .text to be the empty string in the parrot example, but
instead it is None.

I can fix my script to deal with this, but it's surprising. Is it
intentional? I could understand it being None if the doc had said

<foo bar="parrot"/>

but that is different.

Disclaimer: I'm not even slightly an XML expert, I just find myself
having to deal with a lot of it.

previous
next

Re: What sort of C++ skills are needed for a proprietary trader?
Re: struct is saving 4 bytes instead of 2
Re: how can i make a set with comparison function ?
Re: The Modernization of Emacs: terminology buffer and keybinding
Re: Factory function with keyword arguments
Fundacja Hobbit
Mam Marzenie
Fundacja Avalon
Nasze Dzieci
Fundacja Iskierka