This can be done in the following ways.
a) Using Replace function
string xmlData = "
string escapedXmlData = xmlData.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
Note: Replace the & symbol first.
b) Using System.Security.SecurityElement.Escape() method
string xmlData = "
string escapeXmlData = System.Security.SecurityElement.Escape(xmlData);
No comments:
Post a Comment