Dear Stefan,<br><br>I did read your other post, but using the file name directly when calling the parser didn&#39;t work for me. Here is what I tried:<br><br>from lxml import etree<br>outfile = open(&quot;output_test001.txt&quot;, &quot;w&quot;)<br>
class EchoTarget():<br>&nbsp;&nbsp;&nbsp; def start(self, tag, attrib):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if tag.endswith(&quot;xternalPage&quot;):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line = attrib[&quot;about&quot;]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if line != &quot;&quot;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outfile.write(line+&quot;\n&quot;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print line<br>&nbsp;&nbsp;&nbsp; def close(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return &quot;closed!&quot;<br>parser = etree.XMLParser(target = EchoTarget())<br>result = etree.XML(&quot;content.example.xml&quot;, parser)<br><br>This gives the following error:<br>
<br>Traceback (most recent call last):<br>&nbsp; File &quot;extract_links_dmoz005.py&quot;, line 15, in &lt;module&gt;<br>&nbsp;&nbsp;&nbsp; result = etree.XML(&quot;content.example.xml&quot;, parser)<br>&nbsp; File &quot;lxml.etree.pyx&quot;, line 2358, in lxml.etree.XML<br>
&nbsp; File &quot;parser.pxi&quot;, line 1354, in lxml.etree._parseMemoryDocument<br>&nbsp; File &quot;parser.pxi&quot;, line 1243, in lxml.etree._parseDoc<br>&nbsp; File &quot;parser.pxi&quot;, line 795, in lxml.etree._BaseParser._parseDoc<br>
&nbsp; File &quot;parsertarget.pxi&quot;, line 130, in lxml.etree._TargetParserContext._handleParseResultDoc<br>&nbsp; File &quot;parser.pxi&quot;, line 478, in lxml.etree._raiseParseError<br>lxml.etree.XMLSyntaxError: Start tag expected, &#39;&lt;&#39; not found, line 1, column 1<br>
<br><br>I have been reading the docs, but I&#39;m new to processing XML in Python, so I don&#39;t find them all that easy to understand. I think I&#39;m improving, though :) Thanks for your patience.<br><br>Best,<br><br>Sam<br>
<br><br><div class="gmail_quote">2008/5/24 Stefan Behnel &lt;<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
did you read my other post?<br>
<div class="Ih2E3d"><br>
Sam Kuper wrote:<br>
&gt; result = etree.XML(infile.read(), parser)<br>
<br>
</div>make that<br>
<br>
 &nbsp; &nbsp;result = etree.parse(&quot;thefile.xml&quot;, parser)<br>
<br>
and consider reading the parser docs on the web page.<br>
<font color="#888888"><br>
Stefan<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><a href="http://five.sentenc.es">http://five.sentenc.es</a> | <a href="http://tinyurl.com/3x9se4">http://tinyurl.com/3x9se4</a><br>--<br>Mr Sam Pablo Kuper BSc MRI<br>
Research Assistant<br>Darwin Correspondence Project<br>Cambridge University Library<br>West Road<br>Cambridge CB3 9DR<br><a href="mailto:spk30@cam.ac.uk">spk30@cam.ac.uk</a><br>Office: +44 (0)1223 333008<br>Mobile: +44 (0) 7971858176<br>
<a href="http://www.darwinproject.ac.uk">www.darwinproject.ac.uk</a>