private String EscapeXML(String str)
{
StringBuilder sb = new StringBuilder();
foreach (Char c in str)
{
switch (c) {
case '&':
sb.Append("&");
break;
case '<':
sb.Append("<");
break;
case '>':
sb.Append(">");
break;
case '\'':
sb.Append("'");
break;
case '"':
sb.Append(""");
break;
default:
sb.Append(c);
break;
}
}
return sb.ToString();
}