Module: ActiveSupport::XmlMini_NokogiriSAX

Extended by:
XmlMini_NokogiriSAX
Included in:
XmlMini_NokogiriSAX
Defined in:
lib/active_support/xml_mini/nokogirisax.rb

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.



68
69
70
# File 'lib/active_support/xml_mini/nokogirisax.rb', line 68

def document_class
  @document_class
end

Instance Method Details

#parse(data) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/active_support/xml_mini/nokogirisax.rb', line 71

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

  char = data.getc
  if char.nil?
    {}
  else
    data.ungetc(char)
    document = self.document_class.new
    parser = Nokogiri::XML::SAX::Parser.new(document)
    parser.parse(data)
    document.hash
  end
end