Adam200214
Adam200214

Reputation: 17

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.

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:

    <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.

Upvotes: 1

Views: 1936

Answers (2)

Robby Cornelissen
Robby Cornelissen

Reputation: 97152

You cannot have multiple root elements in one XML document for it to be well-formed.

You would either have to

  1. split up the document, or
  2. wrap the entire contents in a new root element, e.g.

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

Upvotes: 2

Eugene Borisov
Eugene Borisov

Reputation: 89

Each XML document has exactly one single root element.

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

Upvotes: 1

Related Questions