Rails XML parsing
There are a lot of Ruby XML parsing libraries. However, if your XML is small, you can use the ActiveSupport Hash extension .from_xml
:
Hash.from_xml(x)["message"]["param"].inject({}) do |result, elem|
result[elem["name"]] = elem["value"]
result
end
# => {"msg"=>"xxxxxxxxxxxxx", "messageType"=>"SMS", "udh"=>nil, "id"=>"xxxxxxxxxxxxxx", "target"=>"xxxxxxxxxxxxx", "source"=>"xxxxxxxxxxx"}
You should use Nokogiri for parsing xml. Its pretty fast.