class Nokogiri::XML::SAX::PushParser

def finish

Nokogiri::XML::SAX::Document#end_document to be called.
Finish the parsing. This method is only necessary for
##
def finish
  write '', true
end

def initialize(doc = XML::SAX::Document.new, file_name = nil, encoding = 'ASCII')

an optional +file_name+ and +encoding+
Create a new PushParser with +doc+ as the SAX Document, providing
##
def initialize(doc = XML::SAX::Document.new, file_name = nil, encoding = 'ASCII')
  @document = doc
  @encoding = encoding
  @sax_parser = XML::SAX::Parser.new(doc)
  ## Create our push parser context
  initialize_native(@sax_parser, file_name)
end

def initialize_native(sax, filename) # :nodoc:

:nodoc:
def initialize_native(sax, filename) # :nodoc:
  filename = filename.to_s unless filename.nil?
  ctx_ptr = LibXML.xmlCreatePushParserCtxt(
    sax.cstruct, nil, nil, 0, filename
    )
  raise(RuntimeError, "Could not create a parser context") if ctx_ptr.null?
  self.cstruct = LibXML::XmlSaxPushParserContext.new(ctx_ptr) ;
  self
end

def native_write(chunk, last_chunk) # :nodoc:

:nodoc:
def native_write(chunk, last_chunk) # :nodoc:
  size = 0
  unless chunk.nil?
    chunk = chunk.to_s
    size = chunk.length
  end
  rcode = LibXML.xmlParseChunk(cstruct, chunk, size, last_chunk ? 1 : 0)
  if rcode != 0
    error = LibXML.xmlCtxtGetLastError(cstruct)
    raise Nokogiri::XML::SyntaxError.wrap(error)
  end
  self
end

def write chunk, last_chunk = false

that can be called will be called immidiately.
Write a +chunk+ of XML to the PushParser. Any callback methods
##
def write chunk, last_chunk = false
  native_write(chunk, last_chunk)
end