Mega Code Archive

 
Categories / Python / XML
 

Structure of a Program to Process a Document with a _DTD Using SAX

import sys from xml.sax import make_parser from xml.sax import handler class SimpleDTD(handler.DTDHandler):          def notationDecl(self,name,publicid,systemid):              print "notationDecl: ", name, publicid, systemid          def unparsedEntityDecl(self,name,publicid,systemid,ndata):              print "unparsedEntityDecl: ", name, publicid, systemid, ndata     p = make_parser()     p.setDTDHandler(SimpleDTD())     p.parse(sys.argv[1])