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.

ParserMessage
libxml2 / xmllintOpening and ending tag mismatch: To line 2 and to
Firefox DOMParserXML Parsing Error: mismatched tag. Expected: </To>.
Chrome DOMParsererror on line 2 at column 15: Opening and ending tag mismatch
.NET XmlExceptionThe '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

Triggers the error
<note>
  <To>Alice</to>
</note>
Corrected
<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.

Input
WaitingPaste a document to check it. Validation runs as you type.

Everything runs in this tab. Nothing you paste is uploaded, logged or sent anywhere. Open your network panel and check.

Tools that catch this

Background reading

Errors this fixes

Every XML error, explained