from xml.sax import make_parser
from xml.sax import saxutils
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)
sh = SimpleHandler()
p = make_parser()
p.setContentHandler(sh)
file = "guac.xml"
p.parse(file)
|