# Handsoap: Parsing Attributes

**URL:** <https://www.ruby-forum.com/t/handsoap-parsing-attributes/195326>\
**Category:** Rails\
**Created:** [September 21, 2010, 7:02pm UTC](https://www.ruby-forum.com/t/handsoap-parsing-attributes/195326 "2010-09-21T19:02:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Carlton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9e5f3/32.png) [@Aaron\_Carlton](https://www.ruby-forum.com/u/Aaron_Carlton)\
**Post date:** [September 21, 2010, 7:02pm UTC](https://www.ruby-forum.com/t/handsoap-parsing-attributes/195326/1 "2010-09-21T19:02:45Z")

</div>

Hi,

I am using Handsoap to integrate my Rails app with a SOAP web service,  
and when parsing the XML in the response, I need to change behavior  
depending on an element’s ‘type’ attribute. A snippet of the XML  
response is below:

\<?xml version="1.0" encoding="UTF-8"?\>

\<s:Envelope xmlns:s=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”\>  
\<s:Body\>  
  
  
  
  
2010-09-15T17:25:24.567  
  
\*\*\*\*\*\*\*\*\*\*\*\*9736  
  
2010-08-20T05:52:39.55

I’ve tried to get the Detail node’s ‘type’ attribute using XPATH the  
following ways:

puts (node/“subscriber:Detail”[“@type”]).to\_s  
puts (node/“subscriber:Detail@instance:type”).to\_s

and using a number of namespace combinations, but no luck. Does  
anyone have experience or ideas on parsing XML attribute values using  
Handsoap?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Aaron\_Carlton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9e5f3/32.png) [@Aaron\_Carlton](https://www.ruby-forum.com/u/Aaron_Carlton)\
**Post date:** [September 21, 2010, 7:20pm UTC](https://www.ruby-forum.com/t/handsoap-parsing-attributes/195326/2 "2010-09-21T19:20:54Z")

</div>

I just got it to work using:

puts (node/“subscriber:Detail”).xpath("@instance:type").to\_s

I forgot to mention that in this case, node was a XMLNodeSelection  
instance pointing to . Hopefully this helps  
someone else.
