Hpricot strangeness

D

D. Krmpotic

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
 
P

Phlip

D. Krmpotic said:
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.
 
P

Phlip

D. Krmpotic said:
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_hpricot_1.html
 
D

D. Krmpotic

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,283
Messages
2,571,405
Members
48,101
Latest member
LinetteDeg

Latest Threads

Top