Method: ActiveSupport::XmlMini_LibXML#parse

Defined in:
activesupport/lib/active_support/xml_mini/libxml.rb

#parse(data) ⇒ Object

Parse an XML Document string or IO into a simple hash using libxml.

data

XML Document string or IO to parse



14
15
16
17
18
19
20
21
22
23
24
# File 'activesupport/lib/active_support/xml_mini/libxml.rb', line 14

def parse(data)
  if !data.respond_to?(:read)
    data = StringIO.new(data || "")
  end

  if data.eof?
    {}
  else
    LibXML::XML::Parser.io(data).parse.to_hash
  end
end