[英]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你要么必须
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.