XML - 数据在根级别无效 [英] XML - Data At Root Level is Invalid

查看:1298
本文介绍了XML - 数据在根级别无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XSD文件,它是连接codeD的UTF-8,以及任何文本编辑器,我通过运行它不会显示任何字符的文件的开头,但是当我把它在Visual Studio中的调试器,我清楚地看到在文件前面一个空框。

I have an XSD file that is encoded in UTF-8, and any text editor I run it through doesn't show any character at the beginning of the file, but when I pull it up in Visual Studio's debugger, I clearly see an empty box in front of the file.

我也得到了错误:

数据在根级别无效。行1,位置1。

任何人都知道这是什么?

Anyone know what this is?

更新:编辑职位的资格文件的类型。它是由微软的XSD创建者创建的XSD文件。

Update: Edited post to qualify type of file. It's an XSD file created by Microsoft's XSD creator.

推荐答案

事实证明,答案是我所看到的是一个的字节顺序标记,这是一个字符,告诉无论是加载文档是什么EN $ C $光盘,在我的情况,这是恩codeD的UTF-8,所以相应的BOM是 EF BB BF ,如下图所示。要删除它,我打开了它在记事本+ + 和UTF-点击恩code 8无BOM,如下图所示:

It turns out, the answer is that what I'm seeing is a Byte Order Mark, which is a character that tells whatever is loading the document what it is encoded in. In my case, it's encoded in utf-8, so the corresponding BOM was EF BB BF, as shown below. To remove it, I opened it up in Notepad++ and clicked on "Encode in UTF-8 without BOM", as shown below:

.

要真正看到的BOM,我不得不在 TextPad 在二进制模式,打开它并进行了<一href="http://www.google.com/search?hl=en&q=EF+BB+BF&btnG=Google+Search&aq=f&oq=">Google搜索 EF BB BF

To actually see the BOM, I had to open it up in TextPad in Binary mode:, and conducted a Google search for "EF BB BF".

我花了大约8个小时,找出这是什么导致它,所以我想我会和大家一起分享。

It took me about 8 hours to find out this was what was causing it, so I thought I'd share this with everyone.

更新:如果我读了乔尔斯波斯基的博客文章:绝对最低每一个软件开发人员绝对,正面必须了解统一code和字符集(没有借口!)的话,我可能不会有这个问题。

Update: If I had read Joel Spolsky's blog post: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!), then I might not have had this problem.

这篇关于XML - 数据在根级别无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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