Class Nokogiri::XML::SAX::PushParser
In: lib/nokogiri/ffi/xml/sax/push_parser.rb
lib/nokogiri/xml/sax/push_parser.rb
ext/nokogiri/xml_sax_parser.c
Parent: Object

PushParser can parse a document that is fed to it manually. It must be given a SAX::Document object which will be called with SAX events as the document is being parsed.

Calling PushParser#<< writes XML to the parser, calling any SAX callbacks it can.

PushParser#finish tells the parser that the document is finished and calls the end_document SAX method.

Example:

  parser = PushParser.new(Class.new(XML::SAX::Document) {
    def start_document
      puts "start document called"
    end
  }.new)
  parser << "<div>hello<"
  parser << "/div>"
  parser.finish

Methods

<<   finish   initialize_native   native_write   new   write  

Attributes

document  [RW]  The Nokogiri::XML::SAX::Document on which the PushParser will be operating

Public Class methods

Create a new PushParser with doc as the SAX Document, providing an optional file_name and encoding

Public Instance methods

<<(chunk, last_chunk = false)

Alias for write

Finish the parsing. This method is only necessary for Nokogiri::XML::SAX::Document#end_document to be called.

Initialize the push parser with xml_sax using filename

Write chunk to PushParser. last_chunk triggers the end_document handle

Write a chunk of XML to the PushParser. Any callback methods that can be called will be called immidiately.

[Validate]