I want to evaluate XML documents with this kind of structure:
<?xml version="1.0" encoding="UTF-8"?>
<Service_name version="3.3.0">
...
where Service_name
tag name is not constant string, while version
attribute is required.
For that purpose this xpath expression: /*[1]/@version
evaluates fine with any xpath processor, but I can't figure how with Python ElementTree.
For example:
import xml.etree.ElementTree as ET
doc = ET.parse('sample.xml')
v = find('/*[1]/@version').text
raises KeyError: '@'
I tried similar combinations but none that worked.
How can I get version number from above example document with ElementTree?