Quick answer

The closing tag must use the same name as the corresponding opening tag.

XML Mismatched Closing Tag

The closing tag must use the same name as the corresponding opening tag. Case and spelling must match exactly.

Common causes

How to fix

Examples

Bad

<root>
  <Item>x</item>
</root>

Good

<root>
  <Item>x</Item>
</root>

XML mismatched closing tag errors happen when an element is closed with a different name than the one used to open it. In XML, tag names must match exactly, including spelling and letter case, so <Item> must be closed with </Item>, not </item> or </Items>. This validator page helps developers, content editors, API integrators, and automation systems identify the source of the mismatch quickly so XML documents can be parsed reliably by browsers, parsers, feeds, and downstream systems.

How This Validator Works

This XML error checker focuses on structural correctness in well-formed XML. It compares each opening tag with its corresponding closing tag and flags cases where the names do not match exactly. Because XML is case-sensitive, the validator treats <tag> and <Tag> as different elements. It is useful for locating mistakes introduced during manual editing, templating, copy-paste operations, or automated generation.

Common Validation Errors

Where This Validator Is Commonly Used

Why Validation Matters

XML is designed for precise machine parsing, so even a small tag mismatch can prevent a document from being read correctly. Validation helps catch structural issues before they reach production systems, reducing failed imports, broken feeds, and integration errors. It also improves debugging efficiency by pointing directly to the element boundary that needs correction. For teams that exchange structured data, well-formed XML is a basic reliability requirement.

Technical Details

Example Status Reason
<price>10</price> Valid Opening and closing tag names match exactly.
<price>10</Price> Invalid Case does not match.
<item><name>A</item></name> Invalid Tags are closed in the wrong order.

FAQ

What does “mismatched closing tag” mean in XML?

It means the closing tag does not exactly match the corresponding opening tag. In XML, the names must be identical, including capitalization. For example, <book> must be closed with </book>. If the names differ, the document is not well-formed and many parsers will stop processing it.

Is XML case-sensitive?

Yes. XML tag names are case-sensitive, so <Item> and <item> are different elements. This is one of the most common reasons for mismatched closing tag errors, especially when content is edited manually or generated from mixed-case templates.

Can a mismatched tag break an entire XML file?

Yes. A single mismatched closing tag can make the whole document invalid, depending on where the parser encounters the error. Some tools stop at the first issue, while others may report multiple downstream errors caused by the original mismatch. Fixing the first structural error is usually the best starting point.

Why does the parser point to a different line than the actual mistake?

XML parsers often detect the problem only when they reach the closing tag that no longer fits the expected structure. The real mistake may be earlier in the file, such as a missing closing tag or a nested element closed out of order. Reviewing the surrounding element stack usually helps locate the source.

What is the difference between XML and HTML tag matching?

XML requires exact tag-name matching and strict well-formedness rules. HTML is more forgiving in many browsers, and some tags can be implicitly closed. XML does not allow that flexibility, so every opening tag must have a precise matching closing tag unless it is self-closing.

How do I fix a mismatched closing tag quickly?

Compare the opening and closing tag names character by character, including case. Then check the nesting order of nearby elements to make sure nothing was closed too early or too late. If the XML was generated by code, inspect the template or serializer that produced the tag names.

Do attributes affect tag matching?

No. Attributes do not change whether a tag is considered matched. The validator only compares the element names. However, malformed attributes can still cause separate XML errors, so it is worth checking both the tag structure and the attribute syntax if the document fails validation.

Can self-closing tags cause this error?

Self-closing tags like <br /> or <item /> do not need a separate closing tag, so they do not directly cause mismatched closing tag errors. Problems usually arise when an element that should be self-closing is written with an incorrect separate closing tag, or when surrounding nesting is broken.

What tools are useful after fixing the tag mismatch?

After correcting the mismatch, it is useful to run a broader XML well-formedness check, schema validation if available, and any feed or API-specific validation your system requires. That helps confirm the document is structurally correct and compatible with the consuming application or service.

Related Validators & Checkers

FAQ

Is XML tag name case-sensitive?
Yes. <Root> and </root> are different; the closing tag must match the opening tag exactly.
How do I find the mismatched tag?
Use an XML validator; it will report the line and column of the error.

Fix it now

Try in validator (prefill this example)

Related

All tools · Canonical