What the error means
XML elements nest like boxes: the element opened most recently must be the one closed next. Mismatched closing tag means the parser met an end tag whose name does not match the element currently open. The message usually quotes both names — the one that was expected and the one that was found — along with the line.
In the example, <name> is open, and the next end tag is </Name>. XML is case-sensitive, so Name and name are two different elements, and the parser refuses to treat one as closing the other.
Why it happens
- Case differences.
<Name>/</name>,<Item>/</item>. HTML tolerates this; XML does not. - A typo in the closing tag.
<address>...</adress>. - Overlapping elements, such as
<b><i>text</b></i>. Each element must be fully inside its parent, so the inner one has to close first. - A missing end tag earlier in the document. If
<name>had no closer, the parser would still be insidenamewhen it reached</user>, and would report</user>as mismatched — the reported tag is correct; an earlier one is missing. - Namespace prefixes that differ between start and end,
<ns:item>...</item>.
How to fix it
- Paste the document into the formatter above. The error card names the expected and actual tags and the line.
- If the two names differ only by case or spelling, correct the closing tag to match the opening tag exactly.
- If the expected tag is one you closed several lines earlier, the real problem is a missing end tag for the expected element; add it in the right place rather than editing the reported line.
- If elements overlap, reorder the closing tags so the most recently opened closes first.
The corrected example:
<user>
<name>Ada</name>
</user>
If it still fails
- Format the document and read the indentation. Each level of nesting is one indent; a closing tag at the wrong depth stands out visually in a way it never does in a single long line.
- If the document is HTML rather than XML — unclosed
<p>or<li>elements are legal there — use HTML Formatter instead; it applies HTML's rules rather than XML's. - XML Validator includes an excerpt of the offending line, which is the fastest way to spot a stray character in a closing tag.
Related errors
Unclosed tag
Add the missing </element> for the start tag the parser names, or make an empty element self-closing with />. Every start tag needs exactly one matching end tag.
XML declaration after content
Move the <?xml ?> declaration to the first byte of the document, remove anything before it (including a byte-order mark), and keep only one declaration per file.