Structure of a Program to Process a Document with a _DTD Using SAX : SAX « XML « Python






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])

   
  








Related examples in the same category

1.Identifying End Element Tags Using SAX Parsing
2.SAX-Based Analysis of the Guacamole Recipe
3.Simple Use of Locator Object Methods