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()
parser.setContentHandler(sh)
parser.parse(open(sys.argv[1]))
|