# Hpricot and XML

**URL:** <https://www.ruby-forum.com/t/hpricot-and-xml/121690>\
**Category:** Ruby\
**Created:** [November 29, 2007, 11:35pm UTC](https://www.ruby-forum.com/t/hpricot-and-xml/121690 "2007-11-29T23:35:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![regularfry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@regularfry](https://www.ruby-forum.com/u/regularfry)\
**Post date:** [November 29, 2007, 11:35pm UTC](https://www.ruby-forum.com/t/hpricot-and-xml/121690/1 "2007-11-29T23:35:54Z")

</div>

Hi all,

I’ve got a little XML parsing problem, and I’d like to use hpricot to  
use it. The following script:

require ‘rubygems’  
require ‘hpricot’

xml = \<\<-XML  
\<gnc:account version=“2.0.0”\>  
act:nameChild Account\</act:name\>  
\<act:id type=“guid”\>4ba14634e8e52775af401ff8ae797316\</act:id\>  
act:typeBANK\</act:type\>  
act:commodity  
cmdty:spaceISO4217\</cmdty:space\>  
cmdty:idGBP\</cmdty:id\>  
\</act:commodity\>  
act:commodity-scu100\</act:commodity-scu\>  
\<act:parent  
type=“guid”\>e83af2b8702f9bfbde73bd723216fe4f\</act:parent\>  
\</gnc:account\>  
XML

doc = Hpricot.XML(xml)  
puts doc.at(“act:id”).inner\_html  
puts doc.at(“act:name”).inner\_html  
puts doc.at(“act:type”).inner\_html  
puts doc.at(“act:parent”).inner\_html

produces the following output:

$ ruby test\_hpricot.rb  
4ba14634e8e52775af401ff8ae797316  
Child Account  
BANK  
test\_hpricot.rb:22: undefined method `inner\_html’ for nil:NilClass  
(NoMethodError)

I _think_ the exception is being caused by hpricot parsing the :parent  
as a pseudoclass. Any ideas as to how I could make that not happen, or  
otherwise make the last line of the script correctly display the guid in  
question?
