views:

29

answers:

0

I'm trying to validate an XmlDocument instance using an XmlSchema object (xsd schema). When I call the Validate method of the XmlDocument my ValidationEventHandler is called, but the Exception.lineNumber and Exception.linePosition are always 0 (zero). This is the code I'm using:

//Validate XML against xsd schema
XmlDocument doc = new XmlDocument();
doc.LoadXml(strXML);
XmlTextReader schemaReader = new XmlTextReader("hdoc.xsd");
XmlSchema schema = XmlSchema.Read(schemaReader, new ValidationEventHandler(schemaVlidationHandler));
doc.Schemas.Add(schema);
doc.Validate(new ValidationEventHandler(xmlDocVlidationHandler));