Suppose I have the the following xml:
<package xmlns="http://example/namespace">
<rating system="au-oflc">PG</rating>
...
</package>
To get the text of an element in the above, I am doing the following:
from lxml import entree
f = open('/Users/David/Desktop/metadata.xml')
metadata_contents = f.read()
node = etree.fromstring(metadata_contents)
rating = node.xpath('//t:rating/text()', namespaces = {'t':'http://example/namespace'})
>>> rating
['PG']
How would I get the value “au-oflc” ?
You need to retrieve the node itself, not its text: