Currently I am struggling to find the proper answer to this, so it would be great if someone could help me solve this. I have a deeper XML which I want to convert into a table. the XML looks like this:
<Motherofall>
<Parent>
<Child>
<val1>XX1</val1>
<Child2>
<val2>YY1</val2>
<val2>YY2</val2>
<Child2>
<val2>YY3</val2>
<val2>YY4</val2>
</parent>
+<parent>
+<parent>
</Motherofall>
So eventually what I want to have as output would be a table with column val1 and a colmun val2. So val1 is repeated twice per parent.
import xml.etree.ElementTree as et
tree = et.parse(last_file)
for node in tree.findall('.//Parent'):
XX = node.find('.//Child')
print(XX.text)
for node2 in tree.findall('.//Child2'):
YY = node2.find('.//val1')
print(YY.text)
As one might notice I am fairly new to this, however I could not find a fitting answer.