method
from_xml
v3.1.0 -
Show latest stable
- Class:
Hash
from_xml(xml)public
No documentation available.
# File activesupport/lib/active_support/core_ext/hash/conversions.rb, line 89
def from_xml(xml)
typecast_xml_value(unrename_keys(ActiveSupport::XmlMini.parse(xml)))
end 1Note
Looks like this method has trouble with attributes:
ex:
require 'rubygems'
require 'bundler'
require 'active_support/core_ext'
require 'pp'
xml =
'<test id="appears">
<comment id="doesnt appear">
it worked
</comment>
<comment>
see!
</comment>
<comment />
</test>'
hash = Hash.from_xml(xml)
pp hash
#=>{"test"=>{"id"=>"appears", "comment"=>["it worked", "see!", nil]}}
# Notice how the id attribute on the first comment element doesn't appear.