A validation error occurred when validating the instance document
The class works on top of an XML reader—typically an instance of the Xml Text Reader class.
The text reader is used to walk through the nodes of the document whereas the validating reader examines and validates each single piece of XML according to the requested validation type.
Although the Xml Validating Reader class inherits from the base class Xml Reader, it really implements internally only a very small set of all the required functionalities.
The line number is something meaningful too - if I can't manage to get some slightly more specific information from the data itself then I can use this.The dependency of validating readers on an existing text reader is particularly evident if you look at the class constructors.An XML validating reader, in fact, cannot be directly initialized from a file.would return -1 given the scenario in the question.However, I would like the answer extended with information that the parser needs an error handler.