![](/img/trans.png)
[英]Error: The markup in the document following the root element must be well-formed
[英]Java XML Problem: 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.
我已經谷歌研究了它並試圖弄清楚我可能做錯了什么。 不過我不知道。 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>
錯誤發生在文件的第二個大約一半處,就在上面
<server name="Test Server">
知道我做錯了什么,我仍然是非常新的 XML(這是我解析的第一個 XML 文件),但我看不出任何錯誤。
一個 XML 文檔中不能有多個根元素,才能使其格式正確。
你要么必須
將整個內容包裝在一個新的根元素中,例如
<advertisements> <advertisement> <!-- ... --> </advertisement> <advertisement> <!-- ... --> </advertisement> </advertisements>
每個 XML 文檔只有一個根元素。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.