简体   繁体   English

读取的XML文档具有0x19十六进制字符

[英]xml document read having 0x19 hex character

Reading xml document with hex 0x19 character C# 使用十六进制0x19字符C#读取xml文档

Apparently the above character is invalid in C# and the XML document I am about to load contains it. 显然,以上字符在C#中无效,并且我要加载的XML文档包含该字符。

Therefore it throws XML exception everytime I try to read it. 因此,每次我尝试读取它时都会引发XML异常。

<description><![CDATA[Whenever I run<br>Whenever I run to you lost one<br>Its never done<br>Just hanging on<br><br>Just past has let me be<br>Returning as if dream<br>Shattered as belief<br><br>If you have to go dont say goodbye<br>If you have to go dont you cry<br>If you have to go I will get by<br>Someday Ill follow you and see you on the other side<br><br>But for the grace of love<br>Id will the meaning of<br>Heaven from above<br><br>Your picture out of time<br>Left aching in my mind<br>Shadows kept alive<br><br>If you have to go dont say goodbye<br>If you have to go dont you cry<br>If you have to go I will get by<br>I will follow you and see you on the other side<br><br>But for the grace of love<br>Id will the meaning of<br>Heaven from above<br><br>Long horses we are born<br>Creatures more than torn<br>Mourning our way home]]></description>

Apparently the above line contains that character 显然,以上一行包含该字符

Just had the same problem. 只是有同样的问题。 0x19 is a control-character (End of Medium) which is pretty much invisible with text editors. 0x19是一个控制字符(中级结尾),在文本编辑器中几乎看不见。 What I did to parse the XML anyway was to replace this char with a space before parsing, like this: 无论如何,我所做的解析XML的工作就是在解析之前用空格替换此char,如下所示:

var xmlString = GetXmlString();
xmlString = xmlString.Replace((char)0x19, ' ');
var doc = new XmlDocument();
doc.LoadXml(xmlString);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM