XML hexadecimal value 0x__, is an invalid character
2016-01-18 14:09
459 查看
XML操作时异常:(十六进制值 0x__) 是无效的字符。
方法一:
设置 CheckCharacters=false。
方法二:
如果在第三方类库中,无法设置CheckCharacters ,那么只能移除无效的字符。 google下都是使用正则来移除,其实应该使用高效的位图算法。
http://stackoverflow.com/questions/21053138/c-sharp-hexadecimal-value-0x12-is-an-invalid-character https://seattlesoftware.wordpress.com/2008/09/11/hexadecimal-value-0-is-an-invalid-character/
方法一:
设置 CheckCharacters=false。
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings { CheckCharacters = false };
方法二:
如果在第三方类库中,无法设置CheckCharacters ,那么只能移除无效的字符。 google下都是使用正则来移除,其实应该使用高效的位图算法。
//[\x00-\x08\x0B\x0C\x0E-\x1F\x26] for (int i = 0x00; i <= 0x08; i++) { XMLInvalidCharMap[i] = true; } XMLInvalidCharMap[0x0b] = true; XMLInvalidCharMap[0x0c] = true; for (int i = 0x0e; i <= 0x1f; i++) { XMLInvalidCharMap[i] = true; } //XMLInvalidCharMap[0x26] = true; //&符号,不应该被过滤
http://stackoverflow.com/questions/21053138/c-sharp-hexadecimal-value-0x12-is-an-invalid-character https://seattlesoftware.wordpress.com/2008/09/11/hexadecimal-value-0-is-an-invalid-character/
相关文章推荐
- 1367:[Baltic2004]sequence 左偏树
- UIALERT使用指南
- 将UIColor转换为RGB值
- 1月18号 UILabel 加上导入.tff格式的字体
- UITableView 状态栏返回顶部 和自定义按钮返回顶部
- 使用CForm类(Form builder)上传文件
- 自增量字段与Guid字段主键的性能对比
- PAT1099 Build A Binary Search Tree
- SQL Server 2016 实时查询统计(Live Query Statistics)
- ios基本控件之UITextView
- ios基本控件之UIView
- ios基本控件之UITextField
- ios基本控件之UITableView
- ios基本控件之UISwitch
- ios基本控件之UISegmentControl
- 1月18号 UIButton
- ios基本控件之UISlide
- ios基本控件之UIScrollView
- ios基本控件之UIPickerView
- ios基本控件之UIPageControl