Handsoap: Parsing Attributes


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/">
    <RetrieveEWalletForSubscriberResponse xmlns="http://
      <FaultDetails xmlns:a="http://schemas.datacontract.org/2004/07/
ContentDirect.Framework.Contract.Message" xmlns:i="http://www.w3.org/
2001/XMLSchema-instance" i:nil="true"/>
      <PaymentInstruments xmlns:i="http://www.w3.org/2001/XMLSchema-
          <Detail i:type="PaymentInstrumentCreditCard">

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

Thanks in advance!

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 <PaymentInstrument>. Hopefully this helps
someone else.