XML。在文档顶层无效。处理资源时出错
您能指出以下 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
至少我找到了问题的根源!该错误与 XML 无关。
问题发生在FTP类中。
原始代码创建了额外的字节(值为 0x00)
,这里是修改后的代码。
上传图像时,我在 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)
and here is the revised one.
While uploading images i faced no problem with the FTP class. But when it comes with XML files...
- xml.com
请参阅 XML.com,大约在页面中间。
-- xml.com
See Valid XML Output: Including DOCTYPE Declarations at XML.com, about halfway down the page.