I am wounder, that no one suggestUse pandas. Pandas have a function read_xml(), what is perfect for such flat xmlXML structures.
import pandas as pd
xml = """<foo>
<bar>
<type foobar="1"/>
<type foobar="2"/>
</bar>
</foo>"""
df = pd.read_xml(xml, xpath=".//type")
print(df)
import pandas as pd
xml = """<foo>
<bar>
<type foobar="1"/>
<type foobar="2"/>
</bar>
</foo>"""
df = pd.read_xml(xml, xpath=".//type")
print(df)
Output:
foobar
0 1
1 2
foobar
0 1
1 2