How to escape characters in string in c#
I have this string,and getting an error
string text =
<root><Info id="inseID">17</Info><note><123comments></note></root>
I wanted to convert it to
<root><Info id="inseID">17</Info><note><123comments></note></root>
Use linq to xml.
var text = "<root><Info id=\"inseID\">17</Info><note></note></root>"; var xml = XElement.Parse(text); xml.Element("note").Add("<123comments>"); //string result = xml.ToString(); // will be escaped