[XML-SIG] Fastest SAX parser in PyXML

Albert Chin xml-sig at thewrittenword.com
Tue Sep 23 17:13:02 EDT 2003


I'm parsing a large XML file using the SAX parser with:
  from xml.sax import saxexts, saxlib

  # read pkg-db.xml file
  def read_pkgdb_xml (...):
    xmlh = read_pkg_db (...)
    p = saxexts.make_parser ()
    p.setDocumentHandler (xmlh)
    p.parseFile (fh)
    fh.close ()
    p.close ()

  class read_pkg_db (saxlib.HandlerBase):
    def __init__ (...):
      ...

    def startElement (self, name, attrs):
      ...

    def characters (self, ch, start, length):
      ...

    def endElement (self, name):
      ...

Is this the fastest way? I don't need any validation. I just want the
fastest parser.

-- 
albert chin (china at thewrittenword.com)



More information about the XML-SIG mailing list