On Sat, Mar 29, 2008 at 3:57 PM, Doran, Harold <[EMAIL PROTECTED]> wrote:
> I am a python neophyte who has used python to parse through text files > using basic functions and no OOP experience. I have a need to process some > xml files and from what I am now reading python is the exact tool I need to > work through this issue. > > However, as I read online docs and peruse which books to buy, I am quickly > becoming overwhelmed with the topic and could use some guidance on how to > best tackle my task. > > You can start with this basic example (requires Python 2.5): spam.xml: <monty> <episode number="14">Dinsdale (Face the Press)</episode> <episode number="15">The Spanish Inquisition</episode> <episode number="16">Deja vu</episode> <episode number="17">The Buzz Aldrin Show</episode> <episode number="18">Live From the Grill-O-Mat Snack Bar</episode> <episode number="19">It's a Living</episode> <episode number="20">The Attila the Hun Show</episode> <episode number="21">Archaeology Today</episode> <episode number="22">How to Recognize Different Parts of the Body</episode> <episode number="23">Scott of the Antarctic</episode> <episode number="24">How Not to Be Seen</episode> <episode number="25">Spam</episode> <episode number="26">Royal Episode 13</episode> </monty> spam.py: from xml.etree.ElementTree import ElementTree as ET et = ET(file='spam.xml') for episode in et.findall('episode'): print episode.attrib['number'] + ':', '"' + episode.text + '"' Use standard csv module if you want to produce csv ouput ( http://docs.python.org/lib/module-csv.html). -- kv
-- http://mail.python.org/mailman/listinfo/python-list