class Nokogiri::XML::SAX::ParserContext

def parse_with sax_handler, type = :xml

def parse_with sax_handler, type = :xml
  raise ArgumentError unless XML::SAX::Parser === sax_handler
  sax = sax_handler.cstruct
  cstruct[:sax] = sax
  sax_handler.instance_variable_set(:@ctxt, cstruct)
  LibXML.send(:"#{type}ParseDocument", cstruct)
  cstruct[:sax] = nil
  LibXML.xmlFreeDoc cstruct[:myDoc] unless cstruct[:myDoc].null?
end