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