XML 错误 : Extra content at the end of the document

标签 xml xml-parsing

这是 XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<name>Sample Document</name>
<type>document</type>
<url>http://nsc-component.webs.com/Office/Editor/new-doc.html?docname=New+Document&amp;titletype=Title&amp;fontsize=9&amp;fontface=Arial&amp;spacing=1.0&amp;text=&amp;wordcount3=0</url>
</document>

<document>
<name>Sample</name>
<type>document</type>
<url>http://nsc-component.webs.com/Office/Editor/new-doc.html?docname=New+Document&amp;titletype=Title&amp;fontsize=9&amp;fontface=Arial&amp;spacing=1.0&amp;text=&amp;</url>
</document>

当我打开它时它说:This page contains the following errors: error on line 8 at column 1: Extra content at the end of the document

但是当只有这个的时候:

<document>
<name>Sample</name>
<type>document</type>
<url>http://nsc-component.webs.com/Office/Editor/new-doc.html?docname=New+Document&amp;titletype=Title&amp;fontsize=9&amp;fontface=Arial&amp;spacing=1.0&amp;text=&amp;</url>
</document>

当有两个时为什么要说这个?

最佳答案

你需要一个根节点

<?xml version="1.0" encoding="ISO-8859-1"?>    
<documents>
    <document>
        <name>Sample Document</name>
        <type>document</type>
        <url>http://nsc-component.webs.com/Office/Editor/new-doc.html?docname=New+Document&amp;titletype=Title&amp;fontsize=9&amp;fontface=Arial&amp;spacing=1.0&amp;text=&amp;wordcount3=0</url>
    </document>

    <document>
        <name>Sample</name>
        <type>document</type>
        <url>http://nsc-component.webs.com/Office/Editor/new-doc.html?docname=New+Document&amp;titletype=Title&amp;fontsize=9&amp;fontface=Arial&amp;spacing=1.0&amp;text=&amp;</url>
    </document>
</documents>

关于XML 错误 : Extra content at the end of the document,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16861207/

相关文章:

xml - 没有命名空间属性的模式导入

javascript - 根据项目标签删除 xml 中的行

javascript - 如何为数组生成上一个和下一个按钮?

sql - 在应用 block 中使用需要表参数的标量函数

xml - 在 XSLT 2.0 中对元素进行排序

c# - 如何处理 XmlReader.Create 的异常

javascript - 如何解析作为响应文本收到的 xml?

android - 添加指向从 xml 文件解析的内容的链接

javascript - JQuery和XML调整背景

python - 在python中解析XML文件