public static string replaceSpecialXmlChars(string s)
{
// this takes care of all of the characters except ' and " because
// we are not processing within the context of an attribute
//
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
using (XmlWriter writer = new XmlTextWriter(stringWriter))
{
writer.WriteString(s);
stringWriter.Close();
writer.Close();
}
string result = stringWriter.ToString();
result = result.Replace("\"", """);
result = result.Replace("'", "'");
return result;
}