title: xml response to ruby hash
body: <p>BACKGROUND</p>
  
  <p>I have a XML response from a device REST API I need to pick out a particular key/value pair.  Currently I am use HTTParty get to retrieve the XML and picking out the text.  I think I am doing it the hard way and there must be a much easier method.  </p>
  
  <p>QUESTIONS</p>
  
  <p>Is there an easier way to accomplish this to make it easier to understand and make more reusable?</p>
  
  <p>XML looks like this.  I am trying to pick out the formatted="Off" key/value pair.  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;properties&gt;&lt;property id="ST" value="0" formatted="Off" uom="on/off"/&gt;&lt;/properties&gt;
  </code></pre>
  
  <p>Code I am currently using:</p>
  
  <pre><code>require 'httparty'
  
    class Rest
      include HTTParty
      format :xml
        end
  
    listen_for (/status (.*)/i) do |input|
      command_status input.downcase.strip
      request_completed
    end
  
    def command_status(input)
    inputst = @inputSt[input]
    unless inputst.nil?
        status = status_input(inputst)
        say "#{input} is #{status}" 
    else
        say "I'm sorry, but I am not programmed to check #{input} status." 
    end
   end    
  
   def status_input(input)
      # Battery operated devices do not continuously reports status, thus will be blank until first change after an ISY reboot or power cycle.
      resp = Rest.get(@isyIp + input, @isyAuth).inspect
      resp = resp.gsub(/^.*tted"=&gt;"/, "")
      status = resp.gsub(/", "uom.*$/, "")
      return status.downcase.strip
    end
  </code></pre>