Module: ActiveSupport::XmlMini_LibXMLSAX

Extended by:
XmlMini_LibXMLSAX
Included in:
XmlMini_LibXMLSAX
Defined in:
activesupport/lib/active_support/xml_mini/libxmlsax.rb

Overview

:nodoc:

Defined Under Namespace

Classes: HashBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#document_classObject

Returns the value of attribute document_class



62
63
64
# File 'activesupport/lib/active_support/xml_mini/libxmlsax.rb', line 62

def document_class
  @document_class
end

Instance Method Details

#parse(data) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'activesupport/lib/active_support/xml_mini/libxmlsax.rb', line 65

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

  if data.eof?
    {}
  else
    LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER)
    parser = LibXML::XML::SaxParser.io(data)
    document = document_class.new

    parser.callbacks = document
    parser.parse
    document.hash
  end
end