>>> from xml.etree import ElementTree as et >>> from decimal import Decimal >>> >>> root = et.parse('file/with/your.xml') >>> debits = dict((debit.attrib['category'], >>> Decimal(debit.find('amount').text)) for debit in root.findall('debit')) >>> >>> for cat, amount in debits.items(): ... print '%s: %s' % (cat, amount) ... food: 24.30 car: 909.56 medical: 188.20 savings: 25 withdrawal: 40 supplies: 10.58 clothes: 31.19
-- http://mail.python.org/mailman/listinfo/python-list