class Nokogiri::XML::SAX::PushParser
parser.finish
parser << “/div>”
parser << “<div>hello<”
}.new)
end
puts “start document called”
def start_document
parser = PushParser.new(Class.new(XML::SAX::Document) {
Example:
and calls the end_document SAX method.
PushParser#finish tells the parser that the document is finished
callbacks it can.
Calling PushParser#<< writes XML to the parser, calling any SAX
SAX events as the document is being parsed.
must be given a SAX::Document object which will be called with
PushParser can parse a document that is fed to it manually. It
##
def finish
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 = "UTF-8")
Create a new PushParser with +doc+ as the SAX Document, providing
##
def initialize(doc = XML::SAX::Document.new, file_name = nil, encoding = "UTF-8") @document = doc @encoding = encoding @sax_parser = XML::SAX::Parser.new(doc) ## Create our push parser context initialize_native(@sax_parser, file_name) end
def write(chunk, last_chunk = false)
Write a +chunk+ of XML to the PushParser. Any callback methods
##
def write(chunk, last_chunk = false) native_write(chunk, last_chunk) end