class PCParser(ET.XMLTreeBuilder):

    def __init__(self):
        ET.XMLTreeBuilder.__init__(self)
self._parser.CommentHandler = self.handle_comment

def handle_comment(self, data):
    pass
How to keep comments while parsing XML using Python / ElementTree