简体   繁体   English

Java XML 问题:文档中根元素后面的标记必须格式正确

[英]Java XML Problem: The markup in the document following the root element must be well-formed

I'm receiving this error: [Fatal Error] Adverts.xml:26:2: The markup in the document following the root element must be well-formed. org.xml.sax.SAXParseException; systemId: file:/C:/Users/NULL/Desktop/Adverts.xml; lineNumber: 26; columnNumber: 2; The markup in the document following the root element must be well-formed.我收到此错误: [Fatal Error] Adverts.xml:26:2: The markup in the document following the root element must be well-formed. org.xml.sax.SAXParseException; systemId: file:/C:/Users/NULL/Desktop/Adverts.xml; lineNumber: 26; columnNumber: 2; The markup in the document following the root element must be well-formed. [Fatal Error] Adverts.xml:26:2: The markup in the document following the root element must be well-formed. org.xml.sax.SAXParseException; systemId: file:/C:/Users/NULL/Desktop/Adverts.xml; lineNumber: 26; columnNumber: 2; The markup in the document following the root element must be well-formed.

I have google researched it and tried too figure what I may be possibly doing wrong.我已经谷歌研究了它并试图弄清楚我可能做错了什么。 However I have no idea.不过我不知道。 The XML file goes as such: XML 文件如下:

    <advertisement>
    <server name="Zenith"> 
    <discordlink>http://zenithps.org</discordlink>
    <ownerid>304558905306906624</ownerid>
    <logourl>http://zenithps.org/Zenith%20Logo.png</logourl>
    <feature>Feature1</feature>
    <feature>Feature2</feature>
    <image>C:/Users/NULL/Pictures/Zenith Logo.png</image>
    <image>C:/Users/NULL/Pictures/Description Hovers.gif</image>
    <image>C:/Users/NULL/Pictures/Launcher.png</image>
    <image>C:/Users/NULL/Pictures/Upgrade.gif</image>
    <image>C:/Users/NULL/Pictures/Pet.png</image>
    </server>

    <guild id="642406906580828181">
    <name>Guild</name>
    <advertchannel>658936539803418624</advertchannel>
    <commandchannel>658936539803418624</commandchannel>
    <user>304558905306906624</user>
    <delay>25000</delay>
    </guild>

    </advertisement>


    <advertisement>
    <server name="Test Server"> 
    <discordlink>http://zenithps.org</discordlink>
    <ownerid>304558905306906624</ownerid>
    <logourl>http://zenithps.org/Zenith%20Logo.png</logourl>
    <feature>Feature1</feature>
    <feature>Feature2</feature>
    <image>C:/Users/NULL/Pictures/Zenith Logo.png</image>
    <image>C:/Users/NULL/Pictures/Description Hovers.gif</image>
    <image>C:/Users/NULL/Pictures/Launcher.png</image>
    <image>C:/Users/NULL/Pictures/Upgrade.gif</image>
    <image>C:/Users/NULL/Pictures/Pet.png</image>
    </server>

    <guild id="6424069110828181">
    <name>Test Guild</name>
    <advertchannel>658936539803418624</advertchannel>
    <commandchannel>658936539803418624</commandchannel>
    <user>304558905306906624</user>
    <delay>25000</delay>
    </guild>

    </advertisement>

The error occurs on the second roughly half way through the file, just above错误发生在文件的第二个大约一半处,就在上面

<server name="Test Server"> 

Any idea what I'm doing wrong, I'm still very new XML(this being the first XML file I've parsed) but I cannot see anything wrong.知道我做错了什么,我仍然是非常新的 XML(这是我解析的第一个 XML 文件),但我看不出任何错误。

You cannot have multiple root elements in one XML document for it to be well-formed.一个 XML 文档中不能有多个根元素,才能使其格式正确。

You would either have to你要么必须

  1. split up the document, or拆分文件,或
  2. wrap the entire contents in a new root element, eg将整个内容包装在一个新的根元素中,例如

    <advertisements> <advertisement> <!-- ... --> </advertisement> <advertisement> <!-- ... --> </advertisement> </advertisements>

Each XML document has exactly one single root element.每个 XML 文档只有一个根元素。

https://en.wikipedia.org/wiki/Root_element https://en.wikipedia.org/wiki/Root_element

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:根元素后面的文档中的标记必须格式正确 - Error: The markup in the document following the root element must be well-formed 根元素后面的文档中的标记必须格式正确吗? - The markup in the document following the root element must be well-formed? web.xml根元素后面的文档中的标记必须格式正确 - web.xml the markup in the document following the root element must be well-formed org.xml.sax.SAXParseException 文档中根元素之后的标记必须格式正确 - org.xml.sax.SAXParseException The markup in the document following the root element must be well-formed 错误! Android中的编程-Java开发人员-根元素后的文档中的标记必须格式正确 - ERROR ! in Android - java developer - The markup in the document following the root element must be well-formed Eclipse错误“根元素后面的文档中的标记必须格式正确 - Eclipse error "The markup in the document following the root element must be well-formed Tomcat错误:根元素后的文档中的标记必须格式正确 - Tomcat error: The markup in the document following the root element must be well-formed 添加导航抽屉会导致:根元素后面的文档中的标记必须格式正确 - Adding Navigation Drawer results in: The markup in the document following the root element must be well-formed Android 应用程序,根元素后面的文档中的标记必须格式正确 - Android app, The markup in the document following the root element must be well-formed 我收到此错误:根元素后面的文档中的标记必须格式正确 - i am getting this error: The markup in the document following the root element must be well-formed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM