XML error reference · XV003
More than one root element
The document contains a second top-level element. XML allows exactly one.
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 |
| Python ElementTree | junk after document element: line 2, column 0 |
| .NET XmlException | There are multiple root elements. |
What causes it
An XML document has a single document element that contains everything else. This trips people up when concatenating fragments, when a log appends records to a file without a wrapper, or when a database export writes one row element per line with no surrounding container. Each fragment is individually well-formed, but the file as a whole is not a valid XML document.
See it happen
<record id="1"/>
<record id="2"/><records>
<record id="1"/>
<record id="2"/>
</records>How to fix it
Wrap the top-level elements in a single container element. If you genuinely need a stream of independent documents, use a framing format that carries them: one per line, a multipart body, or an archive. Do not concatenate them into one file.
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.