REALLY simple xml reader
Ivan Illarionov
ivan.illarionov at gmail.com
Wed Jan 30 21:52:43 EST 2008
>>> 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
More information about the Python-list
mailing list