Hi,

Could someone please help me to understand the difference of:

html = Hpricot( "<div><div></div></div>" )
(html/'/div').each do |item|
  x = (item/'/div')[0].to_html
  p x
end

output: "<div></div>"

and

html = Hpricot( "<div><div></div></div>" )
(html/'/div').each do |item|
  p (item/'/div')[0].to_html
end

gives "undefined method `[]' for nil:NilClass (NoMethodError)" in line
3

Shouldn't the code snippets semantically be the same?

Thanks,
Andreas