# Parse xml through "hpricot"

**URL:** <https://www.ruby-forum.com/t/parse-xml-through-hpricot/179080>\
**Category:** Rails\
**Created:** [November 17, 2009, 9:55am UTC](https://www.ruby-forum.com/t/parse-xml-through-hpricot/179080 "2009-11-17T09:55:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chinna\_gogulapati](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@chinna\_gogulapati](https://www.ruby-forum.com/u/chinna_gogulapati)\
**Post date:** [November 17, 2009, 9:55am UTC](https://www.ruby-forum.com/t/parse-xml-through-hpricot/179080/1 "2009-11-17T09:55:49Z")

</div>

Hi All,

The follwoing is my xml  
\<soap:Envelope xmlns:soap=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”\>  
soap:Body  
  
  
  
  
.  
.  
.  
.  
.  
  
.  
.  
  
  
\</soap:Body\>  
\</soap:Envelope\>  
by the following code i could reach up to parent node by using hpricot.  
Now i need “Id” attribute value of all 's for each parent.  
Can any one help me.

require ‘rubygems’  
require ‘hpricot’  
doch = Hpricot(resp\_data.receive\_string)  
doch.search(“parent”).each do |parent|  
puts parent.attributes[‘name’]  
puts (parent/“refinement”)  
end

Thanx  
Chinna.
