Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

XML document append child and escape special characters

$
0
0

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?

 


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>