Inner_html = "" in hpricot

hey all

I’m using hpricot 0.8.1. I’m setting the contents of some tags using
the inner_html method, and if any of the values i set happen to be empty
strings, it blows up:

xml.search("/data/score/composer").inner_html = “foo”
=> “foo”
xml.search("/data/score/composer").inner_html = “”

/var/lib/gems/1.8/gems/hpricot-0.8.1/lib/hpricot/traverse.rb:198:in
reparent': undefined methodparent=’ for nil:NilClass (NoMethodError)
from
/var/lib/gems/1.8/gems/hpricot-0.8.1/lib/hpricot/traverse.rb:198:in
each' from /var/lib/gems/1.8/gems/hpricot-0.8.1/lib/hpricot/traverse.rb:198:inreparent’
from
/var/lib/gems/1.8/gems/hpricot-0.8.1/lib/hpricot/traverse.rb:177:in
html' from /var/lib/gems/1.8/gems/hpricot-0.8.1/lib/hpricot/traverse.rb:192:ininner_html=’
from
/var/lib/gems/1.8/gems/hpricot-0.8.1/lib/hpricot/elements.rb:96:in
inner_html=' from /var/lib/gems/1.8/gems/hpricot-0.8.1/lib/hpricot/elements.rb:96:ineach’
from
/var/lib/gems/1.8/gems/hpricot-0.8.1/lib/hpricot/elements.rb:96:in
`inner_html=’

Anyone know
a) why this is happening and/or
b) a way to set the contents of these tags that won’t error on empty
strings?

thanks, max

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs