def characters(self, content):
    if self._forward_events():
        super().characters(content)

def main():
    tag_names_to_exclude = {'project1', 'project2', 'project3'}
reader = Project1Filter(tag_names_to_exclude, make_parser())
with open('out-small.xml', 'w') as f:
    handler = XMLGenerator(f)
reader.setContentHandler(handler)
reader.parse('input.xml')
if __name__ == '__main__':
    main()
How to use xml sax parser to read and write a large xml?