I have a xml file (a1.xml).
<object>
<label id="0">Helmet</label>
<bndbox id="0">
<xmin>295</xmin>
<ymin>304</ymin>
</bndbox>
<label id="1">Person</label>
<bndbox id="1">
<xmin>279</xmin>
<ymin>291</ymin>
</bndbox>
</object>
I want to get this format
obj = [{'label': 'Helmet', 'xmin': 295, 'ymin': 304},
{'label': 'Person', 'xmin': 279, 'ymin': 291}]
my code as following
import xml.etree.cElementTree as ET
tree = ET.parse('a1.xml')
for subtag in root.findall('object'):
tag = subtag.findall('label').text
x = subtag.findall('xmin').text
y = subtag.findall('ymin').text
How to solve this?