I am facing this specific scenario where my escape sequences are getting replaced twice.
I have a code similar placed similar as below:
XmlDocument xmldoc=new XmlDocument();
XmlNode root=xmldoc.CreateElement("root");
XmlNode node=xmldoc.CreateElement("test");
string str="This is \"Country's\" & nations challenge";
//All escape sequences are removed.Below finctions correctly and replaces all special characters
node.InnerText= System.Security.SecurityElement.Escape(str);
//This will again replace and only & with & is anything wrong here? so text " will be replaced with &qout
root.AppendChild(node);
I tried it by giving node.Innertext=str; just to avoid double replacement but it seems appendchild only replaces & with an &
Is there a proper way to resolve this issue?