method

from_xml

v3.2.13 - Show latest stable - Class: Hash
from_xml(xml, disallowed_types = nil)
public

No documentation available.

# File activesupport/lib/active_support/core_ext/hash/conversions.rb, line 97
    def from_xml(xml, disallowed_types = nil)
      typecast_xml_value(unrename_keys(ActiveSupport::XmlMini.parse(xml)), disallowed_types)
    end

1Note

Looks like this method has trouble with attributes:

backslashen ยท Apr 3, 20121 thank

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.