<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Cambria;
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>Hey all, I’m simply trying to get my feet wet with XML
parsing, and I tried to just do something simple with ElementTree, just throw
the XML tags from a file into a list.  The code is as follows (and may be
wrong):<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:blue'>import</span><span style='font-size:10.0pt;
font-family:"Courier New";color:black'> glob</span><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:blue'>import</span><span style='font-size:10.0pt;
font-family:"Courier New";color:black'> xml.etree.ElementTree </span><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>as</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> ET</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>tree = ET.parse(</span><i><span
style='font-size:10.0pt;font-family:"Courier New";color:#00AA00'>'nameofFilehere'</span></i><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>).getroot()</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>list = []</span><span style='font-size:
10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:blue'>for</span><span style='font-size:10.0pt;
font-family:"Courier New";color:black'> branch </span><span style='font-size:
10.0pt;font-family:"Courier New";color:blue'>in</span><span style='font-size:
10.0pt;font-family:"Courier New";color:black'> tree:</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>    this = {}</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>    </span><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>for</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> child </span><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>in</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> branch.getchildren():</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>       
this[child.tag] = child.text</span><span style='font-size:10.0pt;font-family:
"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>        list.append(this)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:black'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:12.0pt;color:black'>Every time I run
the program, I get this error:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:black'><o:p> </o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>Traceback (most recent call last):</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>  </span><u><span style='font-size:
10.0pt;font-family:"Courier New";color:navy'>File "nameofFilehere",
line 4, in <module></span></u><span style='font-size:10.0pt;font-family:
"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>    coords = ET.parse('nameofFilehere').getroot()</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>  </span><u><span style='font-size:
10.0pt;font-family:"Courier New";color:navy'>File "C:\Program
Files\Python25\Lib\xml\etree\ElementTree.py", line 862, in parse</span></u><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>    tree.parse(source,
parser)</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>  </span><u><span style='font-size:
10.0pt;font-family:"Courier New";color:navy'>File "C:\Program
Files\Python25\Lib\xml\etree\ElementTree.py", line 587, in parse</span></u><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>    self._root =
parser.close()</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>  </span><u><span style='font-size:
10.0pt;font-family:"Courier New";color:navy'>File "C:\Program
Files\Python25\Lib\xml\etree\ElementTree.py", line 1254, in close</span></u><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>   
self._parser.Parse("", 1) # end of data</span><span style='font-size:
10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:red'>xml.parsers.expat.ExpatError: no element found: line 3, column 0<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Cambria","serif";
color:red'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:12.0pt;color:black'>What can I do to
fix this, if anything?  My overall goal has been to simply get the text of
the XML document into a text file, but even that has failed (I get naught but
gibberish), so any help would be appreciated.</span><span style='font-size:
12.0pt;color:black'><o:p></o:p></span></p>

</div>

</body>

</html>