I have an xml file looks like this
<report> #root element
<bindingsite id="1" has_interactions="True">
<interactions> #child elements
<hydrophobic_interactions/> #the sub-child elements I want to get name
<hydrogen_bonds>
<hydrogen_bond id="1">
<resnr>25</resnr>
<restype>ASN</restype>
#Lots of elements after this
</hydrogen_bond>
<hydrogen_bond id="2">
<resnr>26</resnr>
<restype>ALA</restype>
#Lots of elements after this
</hydrogen_bond>
<hydrogen_bond id="3">
<resnr>26</resnr>
<restype>ALA</restype>
#Lots of elements after this
</hydrogen_bond>
<hydrogen_bond id="4">
<resnr>102</resnr>
<restype>THR</restype>
#Lots of elements after this
</hydrogen_bond>
<water_bridges/>
<salt_bridges> #the sub-child elements I want to get name
<salt_bridge id="1">
<resnr>29</resnr>
<restype>ARG</restype>
#Lots of elements after this
</salt_bridge>
<salt_bridge id="2">
<resnr>187</resnr>
<restype>ASP</restype>
#Lots of elements after this
</salt_bridge>
</salt_bridges>
</interactions>
</bindingsite>
</report>
I need to make a Python script to extract the value of the <resnr>
and <restype>
from all the sub-child elements and print with this format
'sub-child element 1 name' 'resnr1''restype1' 'resnr2''restype2' 'resnr3''restype3'
'sub-child element 2 name' 'resnr1''restype1' 'resnr2''restype2' 'resnr3''restype3'
for example, for the above xml file
hydrogen_bonds 25ASN 26ALA 26ALA 102THR
salt_bridge 29ARG 187ASP
Appriciate any help!