I have this xml file layout and I want to extract all children names (Amy, Max, and Derek):
<data>
<dataentry>
<Name>John</Name>
<Birthday>3/3/93</BirthDay>
<Children>
<Child> Amy </Child>
<Child> Max </Child>
<Child> Derek </Child>
</Children>
</dataentry>
<dataentry>
....
</dataentry>
</data>
Python code:
root = tree.getroot()
for dataentry in root.findall('dataentry'):
for children in dataentry.findall('Children'):
for child in children.findall('Child'):
print child.text
I have this nested for loop but is there a faster or more elegant way?