Unexpected end of file while parsing Comment has occurred
A comment is never closed, so it runs to the end of the document.
Unexpected end of file while parsing Comment has occurred. Line 2, position 1.
Why it happens
- A
<!--without its-->, or a comment closed with->or--!>.
How to fix it
Close the comment with -->. The same message with CDATA instead of Comment means an unclosed CDATA section (]]> is missing).
.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 Comment not terminated. It checks the whole document in your browser and lists every schema error with its line and column, not only the first.
Comment not terminated
Example
<note><!-- todo </note>
<note><!-- todo --></note>