XML 解析错误:文档末尾有额外内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12230248/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 13:40:08  来源:igfitidea点击:

XML Parsing error : Extra content at the end of the document

xmlparsingextra

提问by user1640328

Firstly , good day to everyone. I have this script which handles the login to my database : http://pastebin.com/ctUEczRfI used pastebin because it was too long to use code tags. When I run it It returns me this :

首先,祝大家有个美好的一天。我有这个脚本来处理我的数据库的登录:http: //pastebin.com/ctUEczRf我使用了 pastebin 因为它太长而无法使用代码标签。当我运行它时,它返回给我:

This page contains the following errors:

error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.

I don't know how to solve it , I never used XML before. This was given to me along with the CMS.

我不知道如何解决它,我以前从未使用过 XML。这是与 CMS 一起提供给我的。

回答by barefootliam

Pasting the XML that's generated is probably what you'd need to do. My guess is that you are generating XML with multiple top-level elements; XML requires that you have a single wrapper element at the top level and have all other elements inside it: it's a tree, not a forest.

粘贴生成的 XML 可能是您需要做的。我的猜测是您正在生成具有多个顶级元素的 XML;XML 要求您在顶层有一个单一的包装元素,并在其中包含所有其他元素:它是一棵树,而不是森林。

My second guess is that you are seeing the error in your Web browser, and it is not being generated by php at all; check your Web server error logs to make sure.

我的第二个猜测是您在 Web 浏览器中看到了错误,而它根本不是由 php 生成的;检查您的 Web 服务器错误日志以确保。

回答by piersb

Look at the XML. It should look something like the following:

查看 XML。它应该如下所示:

<block>
    <item>Here's an item</item>
    <item>Here's another item</item>
    <item>Here's an item with some sub-items
        <subitem>one</subitem>
        <subitem>two</subitem>
    </item>
</block>

The root of the XML document is the blockitem; it's the item that encloses and surrounds all of the other items.

XML 文档的根是block项目;它是包围和包围所有其他项目的项目。

If you don't have a root - ie, if the code looks something like this:

如果您没有根 - 即,如果代码如下所示:

<item>Here's a list of items</item>
<item>But there's no root element</item>

Then you'll get the error you describe.

然后你会得到你描述的错误。

回答by hugh

I had this error message "Extra content at the end of the document". Turned out the issue was in one of the tags there was no space between two attributes.

我收到此错误消息“文档末尾有额外内容”。原来问题出在其中一个标签中,两个属性之间没有空格。

回答by subbu

Two possible options. It might be because the rendered XML is not valid. Sometimes, it might be because you don't have enough permissions to access the XML.

两种可能的选择。这可能是因为呈现的 XML 无效。有时,这可能是因为您没有足够的权限来访问 XML。