I have a string (from a CDATA element) that contains description of XML. I need to decode this string into a new string that displays the characters correctly using C#
You might also consider the static parse method from XDocument. I'm not sure how it compares to others mentioned here, but it seems to parse these strings well.
Once you get the resulting XDocument, you could turn around with ToString to get the string back:
string parsedString = XDocument.Parse("<My XML />").ToString();
You can use HTML.Raw. That way the markup is not encoded.
System.Web
System.Net
You can use System.Net.WebUtility.HtmlDecode instead of HttpUtility.HtmlDecode
Useful if you don't want System.Web reference and prefer System.Net instead.
HttpUtility.HtmlDecode(xmlString)
will solve this issue
You just need to replace the scaped characters with their originals.
string stringWanted= existingString.Replace("<", "<")
.Replace("&", "&")
.Replace(">", ">")
.Replace(""", "\"")
.Replace("'", "'");