title: Reading large XML file with Nokogiri
body: <p>I'm having trouble reading a (somewhat) large XML file with Nokogiri, but can't figure out where things are going wrong. The file content looks like the following (just a single node included for readability):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;feed xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0"&gt;&lt;title&gt;End | Globally Sourced Menswear&lt;/title&gt;&lt;link type="self" link="http://www.endclothing.com/eu/"/&gt;&lt;updated&gt;2016-04-02T01:25:30+00:00&lt;/updated&gt;&lt;entry&gt;&lt;g:id&gt;391&lt;/g:id&gt;&lt;g:mpn&gt;WRY3924TY&lt;/g:mpn&gt;&lt;g:color&gt;N/A&lt;/g:color&gt;&lt;g:title&gt;Comme des Garcons x Artek Standard Eau De Toilette&lt;/g:title&gt;&lt;g:link&gt;http://www.endclothing.com/eu/comme-des-garcons-x-artek-standard-eau-de-toilette-wry3924ty.html&lt;/g:link&gt;&lt;g:price&gt;89.00 EUR&lt;/g:price&gt;&lt;g:availability&gt;in stock&lt;/g:availability&gt;&lt;g:brand&gt;CDG Parfum&lt;/g:brand&gt;&lt;g:custom_label_0&gt;Perfume &amp;amp; Fragrance&lt;/g:custom_label_0&gt;&lt;g:condition&gt;new&lt;/g:condition&gt;&lt;g:description&gt;&lt;![CDATA[&lt;p&gt;Founded by 4 young idealists in 1935, Finnish design company Artek produce modern furniture to promote the modern culture of habitation. Here they collaborate with &lt;a href="/brands/comme-des-garcons-parfum"&gt;Comme des Garçons Parfum&lt;/a&gt; to produce a fragrance dubbed 'Standard', ironic for a scent that is anything but.&lt;/p&gt;
  &lt;span style="font-style:italic;"&gt;Notes Include:&lt;/span&gt;
  &lt;ul&gt;
  &lt;li&gt;Thyme&lt;/li&gt;
  &lt;li&gt;Black Pepper&lt;/li&gt;
  &lt;li&gt;Patchouli&lt;/li&gt;
  &lt;li&gt;Cedar Wood&lt;/li&gt;
  &lt;li&gt;Citrus&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;Due to recent changes in regulations, we are unable to ship aftershaves and perfumes to certain destinations outside of the EU. For full details, please email &lt;a href="mailto:info@endclothing.co.uk?subject=Aftershave and Perfume Shipment"&gt;info@endclothing.co.uk&lt;/a&gt; or call +44 191 231 3983.&lt;/p&gt;]]&gt;&lt;/g:description&gt;&lt;g:image_link&gt;http://media.endclothing.com/media/catalog/product/1/8/18-03-2016_commedesgarcons_xartekstandardeaudetoilette_100ml_sh_1.jpg&lt;/g:image_link&gt;&lt;g:additional_image_link&gt;http://media.endclothing.com/media/catalog/product/1/8/18-03-2016_commedesgarcons_xartekstandardeaudetoilette_100ml_sh_2.jpg&lt;/g:additional_image_link&gt;&lt;g:shipping&gt;&lt;g:country&gt;FR&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;9.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;DE&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;9.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;DK&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;9.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;NL&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;9.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;IT&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;9.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;SE&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;9.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;BE&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;9.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;AT&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;IE&lt;/g:country&gt;&lt;g:service&gt;Parcel Force Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;ES&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;LV&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;19.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;HR&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;35.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;CY&lt;/g:country&gt;&lt;g:service&gt;FEDEX Priority Service&lt;/g:service&gt;&lt;g:price&gt;45.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;HU&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;PT&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;19.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;EE&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;25.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;LU&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;9.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;SK&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;BG&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;25.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;GR&lt;/g:country&gt;&lt;g:service&gt;FEDEX Priority Service&lt;/g:service&gt;&lt;g:price&gt;25.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;PL&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;LT&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;19.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;SI&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;FI&lt;/g:country&gt;&lt;g:service&gt;Parcel Force Priority Service&lt;/g:service&gt;&lt;g:price&gt;19.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;CZ&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;LI&lt;/g:country&gt;&lt;g:service&gt;FEDEX Priority Service&lt;/g:service&gt;&lt;g:price&gt;35.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;MC&lt;/g:country&gt;&lt;g:service&gt;DPD Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;g:shipping&gt;&lt;g:country&gt;CH&lt;/g:country&gt;&lt;g:service&gt;Parcel Force Priority Service&lt;/g:service&gt;&lt;g:price&gt;15.00 EUR&lt;/g:price&gt;&lt;/g:shipping&gt;&lt;/entry&gt;&lt;/feed&gt;
  </code></pre>
  
  <p>I've tried the following code to read the stream, and while the separate parts seem to work just fine (<code>data</code> outputs a string which appears to be valid XML to me), Nokogiri appears to be unable to read the string, and just crashes or returns nothing for my xpath queries.</p>
  
  <pre><code>url = "http://www.endclothing.com/media/end_feeds/eu.xml.gz"
  stream = open(url, 'Accept-Encoding' =&gt; 'gzip')
  data = Zlib::GzipReader.new(stream).read
  page = Nokogiri::XML(data)
  
  page.xpath("//entry")
  =&gt; []
  </code></pre>