Handsoap: Parsing Attributes

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/”>
<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:[email protected]: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!

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs