Reputation: 475
I want to parse an XML file with ElementTree but at a certain tag the output is wrong
<descriptions>
<description descriptionType="Abstract">Some Abstract Text
</description>
</descriptions>
So I parse it with the XML function
import xml.etree.ElementTree as ElementTree
root = ElementTree.XML(my_xml)
root.getchildren()[0].items()
and the outcome is:
Out: [('descriptionType', 'Abstract')]
Is there any problem with the XML, I use ElementTree in a wrong way or it's a bug?
Upvotes: 0
Views: 114
Reputation: 2569
I guess you want to get the text. So:
root.getchildren()[0].text
not
root.getchildren()[0].items()
Upvotes: 1
Reputation: 475
It was just that if there are no tags its stored in the text attribute..
Upvotes: 0