名称不能以“1"字符开头,十六进制值 0x31.第 2 行,位置 2 [英] Name cannot begin with the '1' character, hexadecimal value 0x31. Line 2, position 2

查看:48
本文介绍了名称不能以“1"字符开头,十六进制值 0x31.第 2 行,位置 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 应用程序中加载 XML 文件时,我得到 <块引用>

名称不能以1"字符开头,十六进制值 0x31.第 2 行,位置 2.

XML 标签是这样开始的.

<1212041205115912>

我不应该不惜任何代价更改此标签.

我该如何解决这个问题?

解决方案

如果 你绝对不能改变它,例如.出于某种原因,该格式已经被其他系统/客户/任何人使用.

既然是无效的xml文档,请在解析前尝试清理.例如.制作一个替换所有 < 的正则表达式number> 带有 < 的标签IMessedUp>数字 然后解析它.

有点不确定的方法,但我会解决你的问题.

While loading XML file in a C# application, I am getting

Name cannot begin with the '1' character, hexadecimal value 0x31. Line 2, position 2.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆