using System.IO; using System.Xml;
StringWriter s = new StringWriter(); XmlTextWriter w = new XmlTextWriter(s); w.WriteString(inputText); string result = s.ToString();
public static string XmlEncode(string input) { input = input.Replace("&", "&"); input = input.Replace("\"", """); input = input.Replace("'", "'"); input = input.Replace("<", "<"); input = input.Replace(">", ">"); return input; }