I have data that looks like it is part of an HTML document. However there are some bugs in it like
<td class= foo"bar">
You are using XML parsers. XML is a strict language, while the HTML standard requires parsers to be tolerant of errors.
Use a compliant HTML parser like
html5lib, or the wrapper library BeautifulSoup (which uses either of the previous with a cleaner API).
html5lib is slower but closely mimics how a modern browser would treat errors.