The markup in the document following the root element must be well-formed
Something follows the root element: an XML document has exactly one.
The markup in the document following the root element must be well-formed.
Why it happens
- Two root elements: several documents concatenated, or a list of records without a wrapper.
- An end tag for the root that comes too early, so what follows is outside it.
- Data appended to a file that was already complete, such as a log of XML messages.
How to fix it
Wrap the elements in one root element, or parse each document separately. Comments and processing instructions may follow the root; elements and text may not.
Java's schema validation (javax.xml.validation.Validator, and JAXB or Spring on top of it) throws at the first error unless you set an ErrorHandler whose error() records the SAXParseException and carries on; each one has getLineNumber() and getColumnNumber(). A well-formedness error ends parsing whatever the handler does.
The same problem in xmlvalid
xmlvalid validates with libxml2, which reports it as Extra content at the end of the document. It checks the whole document in your browser and lists every schema error with its line and column, not only the first.
Extra content at the end of the document
Example
<note/>
<note/>
<notes>
<note/>
<note/>
</notes>