Module: SAXMachine

Defined in:
lib/sax-machine.rb,
lib/sax-machine/version.rb,
lib/sax-machine/ns_stack.rb,
lib/sax-machine/sax_config.rb,
lib/sax-machine/sax_handler.rb,
lib/sax-machine/sax_document.rb,
lib/sax-machine/sax_element_config.rb,
lib/sax-machine/sax_event_recorder.rb,
lib/sax-machine/sax_collection_config.rb

Defined Under Namespace

Modules: ClassMethods, VERSION Classes: NSStack, SAXConfig, SAXEventRecorder, SAXHandler

Constant Summary collapse

EMPTY_STRING =
''
COLON =
':'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/sax-machine/sax_document.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#parse(xml_text) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sax-machine/sax_document.rb', line 9

def parse(xml_text)
  @parser ||= (begin
    sax_handler = SAXHandler.new(self)
    parser = Nokogiri::XML::SAX::PushParser.new(sax_handler)
    if parser.respond_to?(:options)
      parser.options |= Nokogiri::XML::ParseOptions::RECOVER
    end
    parser
  end)
  @parser << xml_text
  self
end

#parse_finishObject



22
23
24
25
26
27
# File 'lib/sax-machine/sax_document.rb', line 22

def parse_finish
  if @parser
    @parser.finish
  end
  self
end