在文档错误的元素内容中发现无效的 XML 字符 (Unicode: 0x0) [英] An Invalid XML character(Unicode: 0x0) was found in the element content of the document error

查看:111
本文介绍了在文档错误的元素内容中发现无效的 XML 字符 (Unicode: 0x0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 XML 文件,它在解析时出现以下错误:在文档错误的元素内容中发现无效的 XML 字符(Unicode:0x0).

I have an XML file which gives me the following error while parsing: An Invalid XML character(Unicode: 0x0) was found in the element content of the document error.

我可以很好地阅读整个内容,而且也没有控制字符.

I can read the whole thing fine, and there are no control characters either.

但是当我自己输入整个内容而不是提供给我的文件时,它工作正常.

But when I typed the whole thing myself instead of a file that was provided to me it worked fine.

可能是什么问题.我通读了一些关于 SO 的类似问题,他们都说这可能是编码问题.但是任何人都可以详细说明这一点,因为我可以阅读整件事.如果是编码问题,我如何通过查看文件知道,因为它看起来不错.它的可读性.我删除了一行并自己输入,该行得到了正确解析.

What could be the issue. I read through some similar questions on SO and they all said that this might be a encoding issue. But can anyone elaborate on this as I could read the whole thing. And if it is encoding issue how would i know by looking at the file because it looks fine. Its readable. I delete a line and type it myself and that line is getting parsed properly.

提前致谢

推荐答案

有两种可能的解释.该文件包含正确编码的 Unicode 代码点 0x0 的实例.XML 不允许使用此字符.

There are two possible explanations. Either the file contains an instance of the Unicode codepoint 0x0, correctly encoded. XML does not allow this character.

或者,解析器认为它看到了 0x0 的实例,因为它错误地解码了文件的物理字节:也就是说,XML 解析器假定的编码不是文件的实际编码.

Alternatively, the parser thought it saw an instance of 0x0 because it was decoding the physical bytes of the file incorrectly: that is, the encoding assumed by the XML parser is not the actual encoding of the file.

在处理此类问题时,您需要非常小心诸如我可以阅读整个文件"和看起来不错"之类的短语.您实际上无法看到磁盘上的位,您只能使用某种查看工具为您解释它们,并且您需要清楚您使用的是什么工具以及它是如何配置的.

When you're dealing with this kind of question you need to be very careful about phrases like "I can read the whole file" and "it looks fine". You can't actually see the bits on the disk, you can only use some kind of viewing tool to interpret them for you, and you need to be clear about what tool you were using and how it was configured.

这篇关于在文档错误的元素内容中发现无效的 XML 字符 (Unicode: 0x0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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