I am trying to validate the values of a XML
through a XSD
file. I'm trying this way:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);
ValidationEventHandler eventHandler = new ValidationEventHandler(ValidationEventHandler);
xmlDoc.Schemas.Add(schemaSet);
xmlDoc.Validate(eventHandler);
static void ValidationEventHandler(object sender, ValidationEventArgs e)
{
switch (e.Severity)
{
case XmlSeverityType.Error:
Console.WriteLine("Error: {0}", e.Message);
break;
case XmlSeverityType.Warning:
Console.WriteLine("Warning {0}", e.Message);
break;
}
}
But when I debug and run the xmlDoc.Validate(eventHandler)
line, I get the following error:
The ' link ' element is not declared.
I have tried several places and I can not solve the problem; How can I resolve this problem?