XML。在文档顶层无效。处理资源时出错

发布于 2024-10-01 19:41:13 字数 1362 浏览 2 评论 0原文

您能指出以下 Xml 文件有什么问题吗?

<?xml version="1.0" encoding="utf-8"?>
<root>
  <align>right</align>
  <columns>3</columns>
  <rows>4</rows>
  <backgroundColor>#333333</backgroundColor>
  <circleButtonColor>#666666</circleButtonColor>
  <currentCircleButtonColor>#000000</currentCircleButtonColor>
  <textColor>#000000</textColor>
  <thumbWidth>100</thumbWidth>
  <thumbHeight>75</thumbHeight>
  <thumbPadding>10</thumbPadding>
  <thumbBorder>3</thumbBorder>
  <thumbBorderColor>#0000F1</thumbBorderColor>
  <assetWidth>600</assetWidth>
  <assetHeight>400</assetHeight>
  <showImageCaption>yes</showImageCaption>
  <showImageShadow>no</showImageShadow>
  <target>_self</target>
</root> 

这是错误,

Invalid at the top level of the document. Error processing resource 'http://www.example.com/xml/setup.xml'. Line 20, Positi...

</root>

我确信我可以使用中断,但如果我不这样做,在上传特定文件之前,我在本地主机上不会收到任何错误。

更新:检查Xml(十六进制)后,我注意到字符0x00(NULL)被神奇地添加到之后>

我说的“神奇”是指...

XML 文件通常在本地主机上创建。 NULL 字符由自定义 FTP 类附加(用于上传 - 以二进制模式),或者其他我无法想象的东西。

could you please point me, what is wrong with the following Xml file?

<?xml version="1.0" encoding="utf-8"?>
<root>
  <align>right</align>
  <columns>3</columns>
  <rows>4</rows>
  <backgroundColor>#333333</backgroundColor>
  <circleButtonColor>#666666</circleButtonColor>
  <currentCircleButtonColor>#000000</currentCircleButtonColor>
  <textColor>#000000</textColor>
  <thumbWidth>100</thumbWidth>
  <thumbHeight>75</thumbHeight>
  <thumbPadding>10</thumbPadding>
  <thumbBorder>3</thumbBorder>
  <thumbBorderColor>#0000F1</thumbBorderColor>
  <assetWidth>600</assetWidth>
  <assetHeight>400</assetHeight>
  <showImageCaption>yes</showImageCaption>
  <showImageShadow>no</showImageShadow>
  <target>_self</target>
</root> 

And here is the error

Invalid at the top level of the document. Error processing resource 'http://www.example.com/xml/setup.xml'. Line 20, Positi...

</root>

I am sure i could use a break, but in case i don't, before i upload the specific file, i get no errors at localhost.

UPDATE: After checking the Xml (Hex), i noticed that the character 0x00 (NULL) was added magically, after the </root>

By saying Magically i mean...

The XML file is created normally at localhost. The NULL character is appended by a custom FTP class, (which is used for upload - in binary mode), OR something else that i cannot imagine..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

前事休说 2024-10-08 19:41:13

至少我找到了问题的根源!该错误与 XML 无关。

问题发生在FTP类中。

原始代码创建了额外的字节(值为 0x00)

Dim fileContents(oFile.Length) As Byte
Using fr As FileStream = oFile.OpenRead
  fr.Read(fileContents, 0, Convert.ToInt32(oFile.Length))
End Using

,这里是修改后的代码。

Dim Length As Integer = oFile.Length - 1
Dim fileContents(Length) As Byte
Using fr As FileStream = oFile.OpenRead
  fr.Read(fileContents, 0, Convert.ToInt32(oFile.Length))
End Using

上传图像时,我在 FTP 类上没有遇到任何问题。但是当它带有 XML 文件时......

At least i found the source of the problem! The error had nothing to do with XML.

The problem occurred in the FTP class.

The original code was creating the extra byte (with the value of 0x00)

Dim fileContents(oFile.Length) As Byte
Using fr As FileStream = oFile.OpenRead
  fr.Read(fileContents, 0, Convert.ToInt32(oFile.Length))
End Using

and here is the revised one.

Dim Length As Integer = oFile.Length - 1
Dim fileContents(Length) As Byte
Using fr As FileStream = oFile.OpenRead
  fr.Read(fileContents, 0, Convert.ToInt32(oFile.Length))
End Using

While uploading images i faced no problem with the FTP class. But when it comes with XML files...

不离久伴 2024-10-08 19:41:13

没有 DOCTYPE 的 XML 文档
声明无效

- xml.com

请参阅 XML.com,大约在页面中间。

an XML document with no DOCTYPE
declaration isn't valid

-- xml.com

See Valid XML Output: Including DOCTYPE Declarations at XML.com, about halfway down the page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文