I have an XML file and I'd like to read some data out of it using Python's xml.etree.
Let's say that the XML file is like this :
<a>
<b>
<c>
<d>This is the text I want to retrieve</d>
</c>
</b>
</a>
What I did was something like this :
document = ElementTree.parse('file.xml')
dToFind = document.find('d')
print(dToFind.text)
But it gave me the following error :
print(dToFind.text)
AttributeError: 'NoneType' object has no attribute 'text'
What did I do wrong? And how can I fix it?
Thanks!