System.XML.XmlException: ' ' is an unexpected token. The expected token is ';'

This issue was caused by a "Name" attribute having a name containing spaces. Once i went through the whole thing and resolved that, I was able to load the HTML as an XML document.


The issue I had turned out to be an ampersand & in a URL where a semi-colon ; did not follow it.

For example:

<a href="http://www.something.com?id=123&name=456"></a>

Fortunately the URL did not need to have the ampersand bit in my HTML code so I removed it altogether. I guess URL encoding would help, replacing it to &amp; if it was needed.