<br><br><div class="gmail_quote">On Sat, Mar 29, 2008 at 3:57 PM, Doran, Harold <<a href="mailto:HDoran@air.org">HDoran@air.org</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">







<div>


<p><font size="2">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.<br>

<br>
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.<br>
<br>
</font></p></div></blockquote><div>You can start with this basic example (requires Python 2.5):<br><br>spam.xml:<br><monty><br>  <episode number="14">Dinsdale (Face the Press)</episode><br>  <episode number="15">The Spanish Inquisition</episode><br>
  <episode number="16">Deja vu</episode><br>  <episode number="17">The Buzz Aldrin Show</episode><br>  <episode number="18">Live From the Grill-O-Mat Snack Bar</episode><br>
  <episode number="19">It's a Living</episode><br>  <episode number="20">The Attila the Hun Show</episode><br>  <episode number="21">Archaeology Today</episode><br>
  <episode number="22">How to Recognize Different Parts of the Body</episode><br>  <episode number="23">Scott of the Antarctic</episode><br>  <episode number="24">How Not to Be Seen</episode><br>
  <episode number="25">Spam</episode><br>  <episode number="26">Royal Episode 13</episode><br></monty><br><br>spam.py:<br>from xml.etree.ElementTree import ElementTree as ET<br>
<br>et = ET(file='spam.xml')<br>for episode in et.findall('episode'):<br>    print episode.attrib['number'] + ':', '"' + episode.text + '"'<br><br><br>Use standard csv module if you want to produce csv ouput (<a href="http://docs.python.org/lib/module-csv.html">http://docs.python.org/lib/module-csv.html</a>).<br>
<br>--<br>kv<br></div></div>