ASCII Table : XML 無效字元處理
產生XML時,會發生如一下資訊 ', hexadecimal value 0x08, is an invalid character. ', hexadecimal value 0x12, is an invalid character. 是某些字元逸出的關系 使用以下REPLACE 處理即可 private string ReplaceHexadecimalSymbols(string txt) { if(txt != "") { string r = "[\x00-\x08\x0B\x0C\x0E-\x1F]"; return Regex.Replace(txt, r, "", RegexOptions.Compiled); } else { return ""; } } ASCII Table 對照表: Dec Char Dec Char Dec Char Dec Char --------- --------- --------- ---------- 0 NUL (null) 32 SPACE 64 @ 96 ` 1 SOH (start of heading) 33 ! 65 A 97 a 2 STX (start of text) 34 " 66 B 98 b 3 ETX (end of text) 35 # 67 C ...