I have code that creates and saves XML fragments. Now I would like to handle HTML as well. ElementTree.write() has a method="html" parameter that suppresses end tags for "area", "base", "basefont", "br", "col", "frame", "hr", "img", "input", "isindex", "link", "meta", and "param" elements. Unfortunately, reading a file that contains those tags throws an error. I'm reluctant to rewrite a lot of my code to use an HTML-specific package. At this point, I'm seriously considering sub-classing the XMLParser to insert an end tag for those tags. Is there an accepted way to do this?
And it just occurred to me that perhaps html.parser.HTMLParser will solve my problems. I will investigate and report back what I find.