I wrote the code below to replace strings but it seemed like there is something wrong with the code. It couldn't replace multiple times. It only can replace the first occurrence. It suppose to replace all occurrences.
//Do not use System.Security.SecurityElement.Escape. I am writing this code for multiple .NET versions.
public string UnescapeXML(string s)
{
if (string.IsNullOrEmpty(s)) return s;
return s.Replace("&", "&").Replace("'", "'").Replace(""", "\"").Replace(">", ">").Replace("<", "<");
}
protected void Page_Load(object sender, EventArgs e)
{
string TestData="TestData&amp;amp;";
Response.Write("using function====>>>>" + UnescapeXML(TestData));
Response.Write("\n\n<BR>Not using function====>>>>" + TestData.Replace("&", ""));
}
s.Conatins("&") == false.