Parsing XML Entity with python xml.sax <p>Parsing XML with python using xml.sax, but my code fails to catch Entities. Why doesn't skippedEntity() or resolveEntity() report in the following: </p> <pre><code>import os import cStringIO import xml.sax from xml.sax.handler import ContentHandler,EntityResolver,DTDHandler #Class to parse and run test XML files class TestHandler(ContentHandler,EntityResolver,DTDHandler): #SAX handler - Entity resolver def resolveEntity(self,publicID,systemID): print "TestHandler.resolveEntity: %s %s" % (publicID,systemID) def skippedEntity(self, name): print "TestHandler.skippedEntity: %s" % (name) def unparsedEntityDecl(self,publicID,systemID,ndata): print "TestHandler.unparsedEntityDecl: %s %s" % (publicID,systemID) def startElement(self,name,attrs): # name = string.lower(name) summary = '' + attrs.get('summary','') arg = '' + attrs.get('arg','') print 'TestHandler.startElement(), %s : %s (%s)' % (name,summary,arg) def run(xml_string): try: parser = xml.sax.make_parser() stream = cStringIO.StringIO(xml_string) curHandler = TestHandler() parser.setContentHandler(curHandler) parser.setDTDHandler( curHandler ) parser.setEntityResolver( curHandler ) parser.parse(stream) stream.close() except (xml.sax.SAXParseException), e: print "*** PARSER error: %s" % e; def main(): try: XML = "&lt;!DOCTYPE page[ &lt;!ENTITY num 'foo'&gt; ]&gt;&lt;test summary='step: &amp;num;'&gt;Entity: &amp;not;&lt;/test&gt;" run(XML) except Exception, e: print 'FATAL ERROR: %s' % (str(e)) if __name__== '__main__': main() </code></pre> <p>When run, all I see is:</p> <pre><code> TestHandler.startElement(), step: foo () *** PARSER error: &lt;unknown&gt;:1:36: undefined entity </code></pre> <p>Why don't I see the resolveEntity print for &amp;num; or the skipped entry print for &amp;not;?</p>