问题描述
在 C# 应用程序中加载 XML 文件时,我得到
名称不能以1"字符开头,十六进制值 0x31.第 2 行,位置 2.
XML 标签是这样开始的.
<1212041205115912>
我不应该不惜任何代价更改此标签.
我该如何解决这个问题?
如果 你绝对不能改变它,例如.出于某种原因,该格式已经被其他系统/客户/任何人使用.
既然是无效的xml文档,请在解析前尝试清理.例如.制作一个替换所有 < 的正则表达式number> 带有 < 的标签IMessedUp>数字 然后解析它.
有点不确定的方法,但我会解决你的问题.
While loading XML file in a C# application, I am getting
The XML tag begins like this.
<version="1.0" encoding="us-ascii" standalone="yes" />
<1212041205115912>
I am not supposed to change this tag at any cost.
How can I resolve this?
IF you absolutely cant change it, eg. for some reason the format is already out in the wild and used by other systems/customers/whatever.
Since it is an invalid xml document, try to clean it up before parsing it.eg. make a regex that replaces all < number> tags with < IMessedUp>number< /IMessedUp> and then parse it.
Sort of iffy way to do it, but I will solve your problem.
这篇关于名称不能以“1"字符开头,十六进制值 0x31.第 2 行,位置 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!