Please find the mwe xml file (The actual file is 81k lines long, I am showing a tiny part).
<?xml version="1.0" encoding="ISO-8859-1"?>
<modeling>
<dos>
<i name="efermi"> -2.48501882 </i>
<total>
<array>
<dimension dim="1">gridpoints</dimension>
<dimension dim="2">spin</dimension>
<field>energy</field>
<field>total</field>
<field>integrated</field>
<set>
<set comment="spin 1">
<r> -55.6029 0.0000 0.0000 </r>
<r> -55.3940 0.0000 0.0000 </r>
<r> -55.1850 0.0000 0.0000 </r>
<r> -54.9761 0.0000 0.0000 </r>
</set>
<set comment="spin 2">
<r> -55.6029 0.0000 0.0000 </r>
<r> -55.3940 0.0000 0.0000 </r>
<r> -55.1850 0.0000 0.0000 </r>
<r> -54.9761 0.0000 0.0000 </r>
</set>
</set>
</array>
</total>
<partial>
<array>
<dimension dim="1">gridpoints</dimension>
<dimension dim="2">spin</dimension>
<dimension dim="3">ion</dimension>
<field>energy</field>
<field> s</field>
<field> py</field>
<field> pz</field>
<field> px</field>
<field> dxy</field>
<field> dyz</field>
<field> dz2</field>
<field> dxz</field>
<field>x2-y2</field>
<set>
<set comment="ion 1">
<set comment="spin 1">
<r> -55.6029 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 </r>
<r> -55.3940 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 </r>
<r> -55.1850 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 </r>
<r> -54.9761 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 </r>
</set>
<set comment="spin 2">
<r> -55.6029 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 </r>
<r> -55.3940 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 </r>
<r> -55.1850 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 </r>
<r> -54.9761 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 </r>
</set>
</set>
</set>
</array>
</partial>
</dos>
</modeling>
The dos tag nested well below, and the values in the component spin 1 etc are not necessarily 0.
I have managed to reach till dos tag, and get the efermi value, but don't understand how to get the sets separately and selectively so that I can plot it using matplotlib.
This is my current code:
#!/usr/bin/env python
import xml.etree.ElementTree as ET
tree = ET.parse("trial.xml")
root = tree.getroot()
for elem in root:
print(elem.tag)
if elem.tag == 'dos':
for x in elem:
print(x.attrib.get('name'), x.text)