XML error reference · XV025
Content after the root element
Text or markup appears after the root element has closed.
What your parser calls it
The same problem, reported differently by each parser. If you arrived here from one of these strings, you are in the right place.
| Parser | Message |
|---|---|
| libxml2 / xmllint | Extra content at the end of the document |
| Firefox DOMParser | XML Parsing Error: junk after document element |
What causes it
Once the root element's end tag is read, only comments, processing instructions and whitespace may follow. Stray text after it, such as a trailing log line, a PHP warning or an HTML error page appended to a response, makes the document invalid. This is closely related to having multiple root elements.
See it happen
<root>
<a/>
</root>
Done.<root>
<a/>
</root>How to fix it
Remove the trailing content. When the XML came from an HTTP response, inspect the raw body: a framework notice or a debug `print` appended after the payload is a very common cause and is invisible in a browser's rendered view.
Fix your own document
Paste your own document below. Press Sample if you want the broken example above loaded instead. Nothing you paste leaves this tab.
XML Validator
Well-formedness and schema validation. Nothing is uploaded.
Everything runs in this tab. Nothing you paste is uploaded, logged or sent anywhere. Open your network panel and check.