Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Hpricot strangeness

Reply
Thread Tools

Hpricot strangeness

 
 
D. Krmpotic
Guest
Posts: n/a
 
      02-12-2008
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-forum.com/.

 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      02-12-2008
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/...2/assert2.html
 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      02-12-2008
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/blo...hpricot_1.html

--
Phlip
http://www.oreillynet.com/ruby/blog/...2/assert2.html
 
Reply With Quote
 
Gregory Seidman
Guest
Posts: n/a
 
      02-12-2008
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/hpr...iki/HpricotXML

> thank you!
> david

--Greg


 
Reply With Quote
 
D. Krmpotic
Guest
Posts: n/a
 
      02-12-2008
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/hpr...iki/HpricotXML
>
>> thank you!
>> david

> --Greg


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VLAN strangeness PabloFiasko Cisco 0 06-01-2005 09:05 AM
Bookmarks Strangeness Drude Firefox 0 01-26-2005 01:28 AM
OT: Friday strangeness Ken Briscoe MCSE 6 05-30-2004 08:19 AM
Strangeness in bookmarks are still occurring Keith Bowes Firefox 0 01-06-2004 11:18 PM
autoincrement strangeness - please help! Munnki Perl 2 12-18-2003 10:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57