Hi,
I got this code to validate my XML against a XSD schema, and it works fine.
static void ValidatingProblemHandler(object sender, ValidationEventArgs e)
{
if ((e.Severity == XmlSeverityType.Warning) || (e.Severity ==
XmlSeverityType.Error))
{
MessageBox.Show(e.Message + " " + String.Format("\n\nLine: {0},
Position: {1} \"{2}\"",
e.Exception.LineNumber, e.Exception.LinePosition,
e.Exception.Message));
}
}
XmlDocument xDoc = new XmlDocument();
xDoc.Load(@"c:\Request.xml");
xDoc.Schemas.Add("",@"c:\ApplicationCompletionRequ est.xsd");
xDoc.Schemas.Compile();
ValidationEventHandler validator = ValidatingProblemHandler;
xDoc.Validate(validator);
I would like to know which node of the document the validation failed, not
only the node name and the value, which could be duplicated in more than one
part in my XML document due to the structure of my XML document
Any suggestion?
Thanks,
Filippo