Extra Closing Tag in XML – Remove Unexpected End Tags

Local only

An extra closing tag appears when the parser encounters </name> but no matching element remains open at that position.

14 chars · 1 line

Waiting for input

Loading XML parser…

XML closing-tag troubleshooting

How to fix an extra closing tag in XML

The sample uses the self-closing <root/> form and then emits </root> again. Because the element was already closed, the second closing tag has no corresponding open element in the parser stack. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • XML well-formedness validation
  • Broken XML example preloaded
  • Corrected XML comparison
  • .xml file import
  • Browser parser feedback
  • Browser-local processing

Steps

  1. Inspect the element immediately before the unexpected closing tag.
  2. Check whether it used the self-closing /> syntax or was already closed earlier.
  3. Remove the duplicate end tag or restore the intended opening element, then validate again.

Self-closing elements already include their closing boundary

The syntax <root/> opens and closes root in one token. Emitting </root> afterward creates a second close operation with no matching open element, which is a well-formedness error.

Extra XML closing tag example

Remove the duplicate closing tag after a self-closing root.

Invalid XML

<root/></root>

Corrected XML

<root/>

Common questions

Frequently asked questions

Does <item/> need </item>?

No. <item/> is already closed.

Can an extra closing tag be caused by templates?

Yes. Conditional branches often duplicate end tags when opening and closing markup are generated separately.

How is this different from a mismatched tag?

A mismatched tag closes the wrong currently open element; an extra closing tag has no matching open element at all.

Debugging a specific XML issue? Browse XML troubleshooting.