Hello All,
I am trying to validate XML file against a XSD. The trouble is, it
does not validate my file if I have the following header:
<?xml version='1.0' encoding='utf-8'?>
It gives me this error:
The data at the root level is invalid. Line 1, position 1.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: The data at the root level
is invalid. Line 1, position 1.
Source Error:
Line 198: vr.Schemas.Add(Nothing, schemaUrl)
Line 199: AddHandler vr.ValidationEventHandler, AddressOf
ValidationHandler
Line 200: While vr.Read()
Line 201: End While
Line 202:
If I remove the encoding i.e if I have this as follows:
<?xml version='1.0'?>
it works.
Can anyone suggest what could be the problem.