I have got the following exception from the below code block.
An error occurred while parsing EntityName. Line1, position 844.
I was trying
Just replace them:
Not valid in XML elements:
" "
' '
< <
> >
& &
public static string UnescapeXMLValue(string xmlString)
{
if (xmlString == null)
throw new ArgumentNullException("xmlString")
return xmlString.Replace("'", "'").Replace(""", "\"").Replace(">", ">").Replace("<", "<").Replace("&", "&");
}
public static string EscapeXMLValue(string xmlString)
{
if (xmlString == null)
throw new ArgumentNullException("xmlString")
return xmlString.Replace("'","'").Replace( "\"", """).Replace(">",">").Replace( "<","<").Replace( "&","&");
}