XML error reference · XV001
Unclosed tag
An element was opened but the document ended before its closing tag appeared.
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 | Premature end of data in tag order line 1 |
| Firefox DOMParser | XML Parsing Error: no element found |
| Java SAXParser | XML document structures must start and end within the same entity. |
| Python ElementTree | no element found: line 3, column 0 |
What causes it
Every XML element that is not self-closing must be closed by a matching end tag. Unlike HTML, XML has no optional end tags and no list of void elements, so a parser cannot guess where you meant an element to stop. This most often happens when XML is assembled by string concatenation, when a document is truncated in transit, or when a loop writes an opening tag on every iteration and the closing tag is written outside the loop.
See it happen
<order>
<item>Widget
</order><order>
<item>Widget</item>
</order>How to fix it
Add the missing end tag, or make the element self-closing with a trailing slash if it is genuinely empty. If you are generating XML in code, use a serialiser rather than string concatenation. Every mainstream language ships one, and none of them can produce an unbalanced document.
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.