15.8. A Template for SAX Drivers

In this section, we develop a template Python SAX driver called template that will illustrate the overall structure of a Python SAX driver. Once this template works, we will customize it for MySQL.

CD-ROM reference=15016.txt
C>type drv_template.py """ Python SAX template driver """ import sys,os,string from xml.sax import saxlib,saxutils # SAX_template #_________________ class SAX_template(saxlib.Parser): """ Template implementation of a SAX parser driver """ def __init__(self): saxlib.Parser.__init__(self) def parse(self,sysID): # Call the start of document handler. self.doc_handler.startDocument() # Start an element called template with no # attributes. self.doc_handler.startElement ( "template", saxutils.AttributeMap({})) ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.