# Simple problem using Nokogiri xml eaderr

**URL:** https://rubytalk.org/t/simple-problem-using-nokogiri-xml-eaderr/56179
**Category:** ruby-talk
**Created:** [12 November 2009 06:01 UTC](https://rubytalk.org/t/simple-problem-using-nokogiri-xml-eaderr/56179 "2009-11-12T06:01:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Philip\_Stephens](https://avatars.discourse-cdn.com/v4/letter/p/e47774/32.png) [@Philip\_Stephens](https://rubytalk.org/u/Philip_Stephens)
#### Post date: [12 November 2009 06:01 UTC](https://rubytalk.org/t/simple-problem-using-nokogiri-xml-eaderr/56179/1 "2009-11-12T06:01:35Z")

</div>

Hi. I am a newbie when it comes to using Nokogiri reader to parse an  
xml file. Here is the xml file I want to parse and sample code:

\<?xml version='1.0' encoding='UTF-8'?\>  
\<inventory\>  
&nbsp;&nbsp;\<tire name="super slick racing tire" /\>  
&nbsp;&nbsp;\<tire name="all weather tire" /\>  
\</inventory\>

> **···**
>
> -----------------------------------------------------------------  
> require 'rubygems'  
> require 'nokogiri'
> 
> io = File.open('test.xml', 'r')  
> reader = Nokogiri::XML::Reader(io)
> 
> reader.each do |node|
> 
> &nbsp;&nbsp;# node is an instance of Nokogiri::XML::Readerruby  
> &nbsp;&nbsp;puts [node.name](http://node.name)
> 
> end
> 
> The following is the error message I get:
> 
> pcs$ ruby1.9 TestNok.rb  
> WARNING: Nokogiri was built against LibXML version 2.6.32, but has  
> dynamically loaded 2.7.5  
> /usr/lib/ruby/1.9.0/nokogiri/xml/reader.rb:60:in `read': ParsePI: PI xm  
> never end ... (Nokogiri::XML::SyntaxError)  
> &nbsp;&nbsp;from /usr/lib/ruby/1.9.0/nokogiri/xml/reader.rb:60:in `each'  
> &nbsp;&nbsp;from TestNok.rb:7:in `\<main\>'  
> \<dummy toplevel\>: [BUG] Segmentation fault  
> ruby 1.9.0 (2008-10-04 revision 19669) [i486-linux]
> 
> -- control frame ----------  
> c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP  
> ---------------------------  
> -- backtrace of native function call (Use addr2line) --  
> 0xb08316  
> 0xa285e7  
> 0xa2866a  
> 0xab1144  
> 0x9a0410  
> 0xa5f315  
> 0xa2b994  
> 0xa2baae  
> 0x80487e8  
> 0x469b56  
> 0x80486e1  
> -------------------------------------------------------  
> Aborted
> 
> Any help would be greatly appreciated.  
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

### Author: ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)
#### Post date: [12 November 2009 10:30 UTC](https://rubytalk.org/t/simple-problem-using-nokogiri-xml-eaderr/56179/2 "2009-11-12T10:30:25Z")

</div>

I suggest you look into this. your code works fine for me (tho I'm running on 1.8.7 as well).

> **···**
>
> On Nov 11, 2009, at 22:01 , Philip Stephens wrote:
> 
> > pcs$ ruby1.9 TestNok.rb  
> > WARNING: Nokogiri was built against LibXML version 2.6.32, but has  
> > dynamically loaded 2.7.5

---

<div class="post-metadata">

### Author: ![Aaron\_Patterson1](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@Aaron\_Patterson1](https://rubytalk.org/u/Aaron_Patterson1)
#### Post date: [12 November 2009 16:34 UTC](https://rubytalk.org/t/simple-problem-using-nokogiri-xml-eaderr/56179/3 "2009-11-12T16:34:35Z")

</div>

^^^^^ Looks like you're using 1.9.0

There are bugs in 1.9.0 which cause nokogiri to crash. I suggest you  
upgrade to the latest 1.9.1 release and reinstall nokogiri.

> **···**
>
> On Thu, Nov 12, 2009 at 03:01:35PM +0900, Philip Stephens wrote:
> 
> > Hi. I am a newbie when it comes to using Nokogiri reader to parse an  
> > xml file. Here is the xml file I want to parse and sample code:
> > 
> > \<?xml version='1.0' encoding='UTF-8'?\>  
> > \<inventory\>  
> > &nbsp;&nbsp;\<tire name="super slick racing tire" /\>  
> > &nbsp;&nbsp;\<tire name="all weather tire" /\>  
> > \</inventory\>  
> > -----------------------------------------------------------------  
> > require 'rubygems'  
> > require 'nokogiri'
> > 
> > io = File.open('test.xml', 'r')  
> > reader = Nokogiri::XML::Reader(io)
> > 
> > reader.each do |node|
> > 
> > &nbsp;&nbsp;# node is an instance of Nokogiri::XML::Readerruby  
> > &nbsp;&nbsp;puts node.name
> > 
> > end
> > 
> > The following is the error message I get:
> > 
> > pcs$ ruby1.9 TestNok.rb  
> > WARNING: Nokogiri was built against LibXML version 2.6.32, but has  
> > dynamically loaded 2.7.5  
> > /usr/lib/ruby/1.9.0/nokogiri/xml/reader.rb:60:in `read': ParsePI: PI xm  
> > never end ... (Nokogiri::XML::SyntaxError)  
> > &nbsp;&nbsp;from /usr/lib/ruby/1.9.0/nokogiri/xml/reader.rb:60:in `each'  
> > &nbsp;&nbsp;from TestNok.rb:7:in `\<main\>'  
> > \<dummy toplevel\>: [BUG] Segmentation fault  
> > ruby 1.9.0 (2008-10-04 revision 19669) [i486-linux]
> 
> --  
> Aaron Patterson  
> [http://tenderlovemaking.com/](http://tenderlovemaking.com/)
