I'm trying to loop over an xml file with elementtree. The file looks a bit like this:
<items>
<item>
<name>Blah</name>
<price>1234</price>
</item>
<item>
<name>Something</name>
<price>2345</price>
</item>
</items>
After reading this with elementtree, I can do this:
for element in doc.findall('/items/item/name):
print element.text
But with one loop, I'd like to get the price too... Something like this...
for element in doc.findall('/items/item'):
print element.name.text
print element.price.text
...but I can't. Not sure what's next - do I need to do another "find" per "element"?
Many thanks for any help!