On 04/07/18 01:08, Alan Gauld via Tutor wrote: > # Now the main code just needs the outer loops: > tree = ET.parse(r'\\DealData.xml') > root = tree.getroot() > deals = [] > for deal in root.findall("Deals"): > for dl in deal.findall("Deal"): > deals.append( Deal(dl) ) > > if dl.id == "706880": > print(dl) #uses __str__() to create string
Sorry, that last loop should be like this: for xml_dl in deal.findall("Deal"): theDeal = Deal(xml_dl) deals.append( theDeal ) if theDeal.id == "706880": print(theDeal) #uses __str__() to create string -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor