REALLY simple xml reader
stefan.behnel-n05pAM at web.de
Tue Jan 29 15:17:55 CET 2008
Ricardo Aráoz wrote:
> I don't know zit about xml, but I might need to, and I am saving the
> thread for when I need it. So I looked around and found some 'real'
> XML document (see below). The question is, how to access <amount>s from
> <debit>s (any category) but not <deposit>s.
> doc = """
> <?xml version="1.0"?>
> <checkbook balance-start="2460.62">
> <title>expenses: january 2002</title>
> <debit category="clothes">
> <payto>Walking Store</payto>
> <deposit category="salary">
> <payor>Bob's Bolts</payor>
Sure, no problem. Just use the XPath expression "//debit/amount", or maybe
"/checkbook/credit/amount", if you prefer. This is basically tree traversal,
so you can check the parents and the children as you see fit.
More information about the Python-list