The element type must be terminated by the matching end-tag
An element is still open when an end tag for another element arrives
The element type "to" must be terminated by the matching end-tag "</to>".
Why it happens
- A missing end tag: the element named in the message was never closed.
- A misspelt or differently cased end tag, or elements closed in the wrong order.
- An HTML habit:
<br>instead of<br/>.
How to fix it
Find the start tag of the element in the message and close it before its parent ends. The line Java reports is where it noticed, usually the parent's end tag, not where the missing tag belongs.
Java's schema validation (javax.xml.validation.Validator, and JAXB or Spring on top of it) throws at the first error unless you set an ErrorHandler whose error() records the SAXParseException and carries on; each one has getLineNumber() and getColumnNumber(). A well-formedness error ends parsing whatever the handler does.
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
<note>
<to>Ana
</note>
<note>
<to>Ana</to>
</note>