I have this xml file that contains many chemical groups and their properties. Here is a snippet of the file:
<groups>
<group name='CH3'>
<mw>15.03502</mw>
<heatCapacity>
<a>19.5</a>
</heatCapacity>
</group>
<group name='CH2'>
<mw>14.02708</mw>
<heatCapacity>
<a>-0.909</a>
</heatCapacity>
</group>
<group name='COOH'>
<mw>45.02</mw>
<heatCapacity>
<a>-24.1</a>
</heatCapacity>
</heatCapacity>
</group>
<group name='OH'>
<mw>17.0073</mw>
<heatCapacity>
<a>25.7</a>
</heatCapacity>
</group>
<\groups>
In my python code that parses this file using ElementTree, I have a list of blocks = ['CH3', 'CH2'] and I want to use this to find two groups. I tried the following:
import elementtree.ElementTree as ET
document = ET.parse( 'groups.xml' )
blocks=['CH3','CH2']
for item in blocks:
group1 = document.find(item)
print group1
And all I get is No. Can you help me?
Many thanks
source
share