[Tutor] Python XML for newbie

David Kidd davekidd at gmail.com
Mon Jul 2 04:56:14 CEST 2012


On Mon, Jul 2, 2012 at 12:31 PM, Sean Carolan <scarolan at gmail.com> wrote:

> How do you say, "If the field is 11, then print the next value"?  The
> raw XML looks like this:
>
> <datum>
> <index>1</index>
> <field>11</field>
> <value>9780470286975</value>
> </datum>
>

Instead of iterating over the whole tree, grab all the <datum> elements
then retrieve the <field> child, check the field value, and if '11', then
pull the <value> value.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120702/35083343/attachment-0001.html>


More information about the Tutor mailing list