I have the following code that works and gives me the expected output.
#!/bin/env python
import xml.etree.ElementTree as e
tree = e.parse("Document.XML")
root = tree.getroot()
vals=[]
Can the following part of the code be a one-liner or any more compact ?
for ch in root.findall('arch'):
for gc in ch.findall('pro'):
vals.append(gc.get('label'))
The libxml2 version I have, doesn't support xpath, please don't suggest that option. The XMl file looks like this:
<projects>
<arch name="arch1">
<pro label="A1" type="B1" state="C1"/>
....
</arch>
....
</projects>