# Nokogiri sax parser error

**URL:** <https://www.ruby-forum.com/t/nokogiri-sax-parser-error/159771>\
**Category:** Ruby\
**Created:** [February 8, 2009, 4:23pm UTC](https://www.ruby-forum.com/t/nokogiri-sax-parser-error/159771 "2009-02-08T16:23:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [February 8, 2009, 4:23pm UTC](https://www.ruby-forum.com/t/nokogiri-sax-parser-error/159771/1 "2009-02-08T16:23:28Z")

</div>

Trying to use the Nokogiri Sax parser. I ran into a problem parsing  
the following:

It chokes on the x="" attribute.

T.

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [February 8, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/nokogiri-sax-parser-error/159771/2 "2009-02-08T16:27:00Z")

</div>

That’s because it’s not valid xml (or html). You’d need to escape the  
\< and \>

\<try x="\<x/\>: /\>

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [February 8, 2009, 4:28pm UTC](https://www.ruby-forum.com/t/nokogiri-sax-parser-error/159771/3 "2009-02-08T16:28:10Z")

</div>

Oops typo…

>

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [February 9, 2009, 1:18am UTC](https://www.ruby-forum.com/t/nokogiri-sax-parser-error/159771/4 "2009-02-09T01:18:30Z")

</div>

On Mon, Feb 09, 2009 at 12:20:52AM +0900, Trans wrote:

> It chokes on the x="" attribute.

Can you be more specific? Are you using the XML SAX parser, or the HTML  
SAX parser? What version of libxml2 do you have?

I tried this document with the HTML SAX parser, and it seemed to handle  
it just fine.

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [February 9, 2009, 9:53pm UTC](https://www.ruby-forum.com/t/nokogiri-sax-parser-error/159771/5 "2009-02-09T21:53:22Z")

</div>

On Feb 8, 7:16 pm, Aaron P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can you be more specific? Are you using the XML SAX parser, or the HTML  
> SAX parser? What version of libxml2 do you have?
> 
> I tried this document with the HTML SAX parser, and it seemed to handle  
> it just fine.

Ah that was it then. I was using the XML SAX parser and I did not  
realize that \< \> had to be escaped in attributes. What was happing was  
the document would basically get cut off after it reached the  
attribute.

The HTML SAX parser handled it without a problem though.

My LibXML version is 2.6.31, btw.

Thanks,  
T.
