Module: ActiveSupport::XmlMini_LibXML

Extended by:
XmlMini_LibXML
Included in:
XmlMini_LibXML
Defined in:
lib/active_support/xml_mini/libxml.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#parse(data) ⇒ Object

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

data

XML Document string or IO to parse



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

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