I have the following XML in a string named 'xml':
<?xml version="1.0" encoding="ISO-8859-1"?>
<Book>
<Page>
<Text>Blah</Text>
</Page>
</Book>
I'm trying to get the value Blah out of it but I'm having trouble with xml.etree.cElementTree. I've tried the find() and findtext() methods but nothing. Eventually I did this:
import xml.etree.cElementTree as ET
...
root = ET.fromstring(xml)
element = root.getchildren()[0].getchildren()[0]
Element now equals the element, which is what I want (for this solution anyway), but how do I get the inner text from it? element.text does not work. Any ideas?
EDIT: element.text gives me None
PS: I am using Python 2.5 atm.
As an extra question: what is a better way to parse xml strings in python?