[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Hpricot strangeness

David Krmpotic

2/12/2008 3:41:00 PM

Hi,

Has anyone noticed the following gotcha/bug(?) with empty xml tags in
hpricot: doc = Hpricot("<div><foo/><span>aaaa</span></div>") ;
doc.at("foo") => {elem <foo> {elem <span> "aaaa" </span>}} versus =>
{emptyelem <foo>} for <foo></foo>

How to get around that?

thank you!
david
--
Posted via http://www.ruby-....

4 Answers

Phlip

2/12/2008 5:33:00 PM

0

D. Krmpotic wrote:

> Has anyone noticed the following gotcha/bug(?) with empty xml tags in
> hpricot: doc = Hpricot("<div><foo/><span>aaaa</span></div>") ;
> doc.at("foo") => {elem <foo> {elem <span> "aaaa" </span>}} versus =>
> {emptyelem <foo>} for <foo></foo>
>
> How to get around that?

I'm not sure I understand the question, but I suspect the XML standard(s)
declare that <foo></foo> is exactly the same as <foo/>, so any XML
implementation has no choice but to treat the contents of foo as NULL or nil.

--
Phlip
http://www.oreillynet.com/ruby/blog/2008/02/as...

Phlip

2/12/2008 6:04:00 PM

0

D. Krmpotic wrote:

> Has anyone noticed the following gotcha/bug(?) with empty xml tags in
> hpricot: doc = Hpricot("<div><foo/><span>aaaa</span></div>") ;
> doc.at("foo") => {elem <foo> {elem <span> "aaaa" </span>}} versus =>
> {emptyelem <foo>} for <foo></foo>

I just got it - Why has an insect where <foo/> is not recognized as zero-length,
then his infamous Hpricot forgiveness thinks it's supplying a missing <foo>
after the </span>. Report this to his Trac system.

He needs a mode to turn the forgiveness off, to become more useful. Here's a
survey of the differences between Hpricot and REXML:

http://www.oreillynet.com/onlamp/blog/2007/08/assert_hpri...

--
Phlip
http://www.oreillynet.com/ruby/blog/2008/02/as...

Gregory Seidman

2/12/2008 6:11:00 PM

0

On Wed, Feb 13, 2008 at 12:40:32AM +0900, D. Krmpotic wrote:
> Has anyone noticed the following gotcha/bug(?) with empty xml tags in
> hpricot: doc = Hpricot("<div><foo/><span>aaaa</span></div>") ;
> doc.at("foo") => {elem <foo> {elem <span> "aaaa" </span>}} versus =>
> {emptyelem <foo>} for <foo></foo>
>
> How to get around that?

http://code.whytheluckystiff.net/hpricot/wiki/...

> thank you!
> david
--Greg


David Krmpotic

2/12/2008 7:05:00 PM

0

Great, thanx.. I did find this before, but somehow it didn't work at the
first try. I did something wrong I guess. thank you again

Gregory Seidman wrote:
> On Wed, Feb 13, 2008 at 12:40:32AM +0900, D. Krmpotic wrote:
>> Has anyone noticed the following gotcha/bug(?) with empty xml tags in
>> hpricot: doc = Hpricot("<div><foo/><span>aaaa</span></div>") ;
>> doc.at("foo") => {elem <foo> {elem <span> "aaaa" </span>}} versus =>
>> {emptyelem <foo>} for <foo></foo>
>>
>> How to get around that?
>
> http://code.whytheluckystiff.net/hpricot/wiki/...
>
>> thank you!
>> david
> --Greg

--
Posted via http://www.ruby-....