I just checked, and the excellent tool Pandoc does indeed support conversion from HTML to XHTML, so that process could be automated.