Xml encoding with StringBuilder
using System;
using System.Collections.Generic;
using System.Text;
public class EncodingUtil
{
public static string XmlEncode(string value)
{
StringBuilder sb = new StringBuilder(value);
sb.Replace("&", "&");
sb.Replace("'", "'");
sb.Replace("\"", """);
sb.Replace(">", ">");
sb.Replace("<", "<");
return sb.ToString();
}
}
Related examples in the same category