title: Parse/read Large XML file with minimal memory footprint
body: <p>I have a very large XML file (300mb) of the following format:</p>
  
  <pre><code>&lt;data&gt;
   &lt;point&gt;
    &lt;id&gt;&lt;![CDATA[1371308]]&gt;&lt;/id&gt;
    &lt;time&gt;&lt;![CDATA[15:36]]&gt;&lt;/time&gt;
   &lt;/point&gt;
   &lt;point&gt;
    &lt;id&gt;&lt;![CDATA[1371308]]&gt;&lt;/id&gt;
    &lt;time&gt;&lt;![CDATA[15:36]]&gt;&lt;/time&gt;
   &lt;/point&gt;
   &lt;point&gt;
    &lt;id&gt;&lt;![CDATA[1371308]]&gt;&lt;/id&gt;
    &lt;time&gt;&lt;![CDATA[15:36]]&gt;&lt;/time&gt;
   &lt;/point&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>Now I need to read it and iterate through the <code>point</code> nodes doing something for each. Currently I'm doing it with Nokogiri like this: </p>
  
  <pre><code>require 'nokogiri'
  xmlfeed = Nokogiri::XML(open("large_file.xml"))
  xmlfeed.xpath("./data/point").each do |item|
    save_id(item.xpath("./id").text)
  end
  </code></pre>
  
  <p>However that's not very efficient, since it parses everything whole hug, and hence creating a huge memory footprint (several GB). </p>
  
  <p>Is there a way to do this in chunks instead? Might be called streaming if I'm not mistaken?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The suggested answer using nokogiris sax parser might be okay, but it gets very messy when there is several nodes within each <code>point</code> that I need to extract content from and process differently. Instead of returning a huge array of entries for later processing, I would much rather prefer if I could access one <code>point</code> at a time, process it, and then move on to the next "forgetting" the previous.</p>