The start tag does not match the end tag

An end tag does not match the start tag it should close.

The message, as .NET reports it
The 'to' start tag on line 2 position 4 does not match the end tag of 'too'. Line 2, position 12.

Why it happens

  • A typo or a different letter case in the end tag.
  • Elements closed in the wrong order, or one never closed.

How to fix it

The message gives both positions: the start tag that is still open and the end tag that was found. Make the end tag match the start tag, or close the element before its parent ends.

.NET throws an XmlSchemaValidationException at the first schema error unless XmlReaderSettings.ValidationEventHandler is set, which then receives every one with its line and position. A well-formedness error is an XmlException and ends reading whatever the settings.

The same problem in xmlvalid

xmlvalid validates with libxml2, which reports it as Opening and ending tag mismatch. It checks the whole document in your browser and lists every schema error with its line and column, not only the first.

Opening and ending tag mismatch: to line 2 and too

Example

Reports the error
<note>
  <to>Ana</too>
</note>
Fixed
<note>
  <to>Ana</to>
</note>