title: Parsing large pseudo-xml files in python
body: <p>I'm trying to parse* a large file (> 5GB) of structured markup data. The data format is essentially XML but there is no explicit root element. What's the most efficient way to do that?</p>
  
  <p>The problem with SAX parsers is that they require a root element, so either I've to add a pseudo element to the data stream (is there an equivalent to Java's SequenceInputStream in Python?) or I've to switch to a non-SAX conform event-based parser (is there a successor of sgmllib?)</p>
  
  <p>The structure of the data is quite simple. Basically a listing of  elements: </p>
  
  <pre><code>&lt;Document&gt;
    &lt;docid&gt;1&lt;/docid&gt;
    &lt;text&gt;foo&lt;/text&gt;
  &lt;/Document&gt;
  &lt;Document&gt;
    &lt;docid&gt;2&lt;/docid&gt;
    &lt;text&gt;bar&lt;/text&gt;
  &lt;/Document&gt;
  </code></pre>
  
  <p>*actually to iterate</p>