SAX-Based Analysis of the Guacamole Recipe : SAX « XML « Python

SAX-Based Analysis of the Guacamole Recipe


import sys
from xml.sax import saxutils
from xml.sax import make_parser

class SimpleHandler(saxutils.DefaultHandler):
    def startElement(self,name,attrs):
        print 'Start: ',name,attrs
    def endElement(self,name):
        print 'End: ',name
    def characters(self,data):
        print 'Data: ', repr(data)

parser = make_parser()
sh = SimpleHandler()


Related examples in the same category

1.Identifying End Element Tags Using SAX Parsing
2.Structure of a Program to Process a Document with a _DTD Using SAX
3.Simple Use of Locator Object Methods