Getting exception while parsing the XML if it contains '&' and '<' characters. I have read somewhere that having these characters in XML means that XML is not valid, but I'm receiving it from third party where I can't reformat it.
Below is my code of XML parsing using XDocument:
string data = profile.Content.ReadAsStringAsync().Result; //Read input
XDocument doc = new XDocument();
if (data != "")
{
string rawHtml = WebUtility.HtmlDecode(data);
doc = XDocument.Parse(rawHtml); //Parse input into XDocument
}
Here, data contains actual XML input and not XML filepath. Please suggest me how to handle these special characters.