# Inner\_html = "" in hpricot

**URL:** <https://www.ruby-forum.com/t/inner-html-in-hpricot/182252>\
**Category:** Ruby\
**Created:** [January 25, 2010, 5:48pm UTC](https://www.ruby-forum.com/t/inner-html-in-hpricot/182252 "2010-01-25T17:48:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [January 25, 2010, 5:48pm UTC](https://www.ruby-forum.com/t/inner-html-in-hpricot/182252/1 "2010-01-25T17:48:29Z")

</div>

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 method`parent=’ 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:in`reparent’  
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:in`inner\_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:in`each’  
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
