XElement xml = XElement.Parse(input);
Even though input string was a valid utf-8 based xml, it was failing with following error.
|
Although, the same string works fine when loaded with XMLDocument and then loading it in XElement (as shown below).
var doc = new XmlDocument(); doc.LoadXml(input); XElement xml = XElement.Parse(doc.InnerXml);
Funny! Hah..
On doing some googling, I found a few work around.
The best way is to replace any hexadecimal character (shown below).
input = Regex.Replace(input, @"\p{C}+", "");
I hope to come back and find better solution. Meanwhile let me know if there is any better (more performant) way or a fix.