XML error reference · XV002
Mismatched closing tag
A closing tag names a different element than the one currently open.
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 | Opening and ending tag mismatch: To line 2 and to |
| Firefox DOMParser | XML Parsing Error: mismatched tag. Expected: </To>. |
| Chrome DOMParser | error on line 2 at column 15: Opening and ending tag mismatch |
| .NET XmlException | The 'To' start tag on line 2 does not match the end tag of 'to'. |
What causes it
XML element names are case sensitive and must match exactly between the start tag and the end tag, so `<Item>` is not closed by `</item>`. The other common source is overlapping rather than nested elements: `<b><i>text</b></i>` looks legal to anyone used to lenient HTML parsers but is not well-formed XML, because elements must nest strictly.
See it happen
<note>
<To>Alice</to>
</note><note>
<To>Alice</To>
</note>How to fix it
Make the closing tag match the opening tag exactly, including case. If tags overlap, re-nest them so that the element opened last is closed first.
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.