I having difficulty in accessing the great-grandchildren using element tree in python. Specifically, I want access the tree of Ev,Ec,St,DU and Si. The full xml is attached together at the bottom of this thread.
I tried the following code, but it return nothing.
import xml.etree.ElementTree as ET
tree = ET.parse('shhs_eval.xml')
root = tree.getroot()
for ScoreEvent in root.findall('Sco'):
Event = ScoreEvent.find('Ev').text
Start = ScoreEvent.find('St').text
print(Event,Start)
Thanks in advance
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<PSG>
<Sof>Compumedics</Sof>
<Ep>30</Ep>
<Scs>
<Sco>
<Ev>Arousal</Ev>
<Ec>Arousal|Arousal ()</Ec>
<St>8062.4</St>
<Du>22.8</Du>
<Si>EMG</Si>
</Sco>
<Sco>
<Ev>N1</Ev>
<Evc>wl|Aw ()</Evc>
<St>8062.4</St>
<Du>22.8</Du>
<Si>EMG</Si>
</Sco>
</Scs>
</PSG>