Reputation: 143
I've just started using lxml, and I got this problem:
In the XML find I have an element with an attribute, for example:
<book category="COOKING">
I'm fine until the point I use:
for elt in doc.getiterator():
...
a=elt.attrib
I get this object back: {'category': 'COOKING'}
How could I convert this into something usable, like a string?
Upvotes: 0
Views: 1009
Reputation: 26627
The attrib
property is a dictionary (i.e. associative array). To get the category
property value as a string you can write elt.attrib['category']
Upvotes: 1