Use python to process XML file

Bruce epost2 at gmail.com
Fri Mar 10 13:07:22 EST 2006


you can use function parse from xml.sax
It takes your xml as the first argument and an
xml.sax.handler.ContentHandler instance as the second.
---
from xml.sax import parse
from xml.sax.handler import ContentHandler

class LogHandler(ContentHandler):
     def startElement(self,name):
          if name=='a':
               #self.do_this()

parse(xmlLog.xml,LogHandler())




More information about the Python-list mailing list