Using xmllint and xpath with a less-than-perfect HTML document?
You should pre-process the HTML with a lenient parser. (That's the main difference: HTML is allowed a much more lax syntax than XML.) That is, try HTML5-Tidy and let XMLLint work on the result:
input HTML | vTidy | vxmllint | vresult