[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Nokogiri sax parser error

Trans

2/8/2009 3:21:00 PM

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

<html>
<head>
</head>
<body>
<try x="<x/>" />
</body>
</html>

It chokes on the x="<x/>" attribute.

T.

4 Answers

msnews.microsoft.com

2/8/2009 3:26:00 PM

0

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

<try x="&lt;x/&gt;: />


On Feb 8, 2009, at 10:20 AM, Trans wrote:

> Trying to use the Nokogiri Sax parser. I ran into a problem parsing
> the following:
>
> <html>
> <head>
> </head>
> <body>
> <try x="<x/>" />
> </body>
> </html>
>
> It chokes on the x="<x/>" attribute.
>
> T.
>


msnews.microsoft.com

2/8/2009 3:27:00 PM

0

Oops typo...

> <try x="&lt;x/&gt;" />


On Feb 8, 2009, at 10:25 AM, Mike Cargal wrote:

> That's because it's not valid xml (or html). You'd need to escape
> the < and >
>
> <try x="&lt;x/&gt;: />
>
>
> On Feb 8, 2009, at 10:20 AM, Trans wrote:
>
>> Trying to use the Nokogiri Sax parser. I ran into a problem parsing
>> the following:
>>
>> <html>
>> <head>
>> </head>
>> <body>
>> <try x="<x/>" />
>> </body>
>> </html>
>>
>> It chokes on the x="<x/>" attribute.
>>
>> T.
>>
>
>


Aaron Patterson

2/9/2009 12:17:00 AM

0

On Mon, Feb 09, 2009 at 12:20:52AM +0900, Trans wrote:
> Trying to use the Nokogiri Sax parser. I ran into a problem parsing
> the following:
>
> <html>
> <head>
> </head>
> <body>
> <try x="<x/>" />
> </body>
> </html>
>
> It chokes on the x="<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.

--
Aaron Patterson
http://tenderlovem...

Trans

2/9/2009 8:52:00 PM

0



On Feb 8, 7:16=A0pm, Aaron Patterson <aa...@tenderlovemaking.com> wrote:

> Can you be more specific? =A0Are you using the XML SAX parser, or the HTM=
L
> SAX parser? =A0What 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.