I am learning Python right now on version 2.6.4 The first thing I am trying to do is trying to parse only the value of an attribute (orderno) and print those out. Secondly I am trying to parse through the XML and find a value of an attribute like 10238 from attribut "orderno", but print out the whole item as a csv line like "10238,1,Hasselblad 501 CM body,2355" Any pointers on how to do it?
from xml.etree import ElementTree
tree = ElementTree.parse('sample.xml')
root = tree.getroot()
for item in root:
    first = item.find('orderno').text
    print first
Data:
<item> 
<orderno>10238</orderno>
<count>1</count>
<name>Hasselblad 501 CM body</name> 
<price>2355</price>
</item> 
<item> 
<orderno>20032</orderno>
<count>1</count>
<name>Carl Zeiss Planar Lens CB 2.8/80 mm</name>
<price>1233</price>
</item> 
<item>
<orderno>30212</orderno>
<count>1</count>
<name>Roll Film 120 Magazine A12</name>
<price>917</price>
</item> 
<items>tagitemtag. Please try it