日期:2014-05-17 浏览次数:21583 次
public static string CleanInvalidXmlChars(string text)
{
// From xml spec valid chars:
// #x9
------解决方案--------------------
#xA
------解决方案--------------------
#xD
------解决方案--------------------
[#x20-#xD7FF]
------解决方案--------------------
[#xE000-#xFFFD]
------解决方案--------------------
[#x10000-#x10FFFF]
// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
string re = @"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u10000-u10FFFF]";
return Regex.Replace(text, re, "");
}