I'm trying to parse a xml with the below content
<File version="5.6">
<Parent name="A">
<Child name="a"/>
<Child name="b"/>
</Parent>
<Parent name="B">
<Child name="c"/>
<Child name="d"/>
</Parent>
<Parent name="C">
<Child name="e"/>
<Child name="f"/>
</Parent>
</File>
And I used the following code
for child in tree.getroot().findall('./Parent/Child')
print child.attrib.get("name")
It just print all the name of children without the parent names. Can I print the relevant parent name of each child like this?
A has a b
B has c d
C has e f