XML and schema

  • Thread starter Thread starter Chris Wagner
  • Start date Start date
You can use XmlVaidatingReader for that purpose:


XmlTextReader xtr = new XmlTextReader("your xml file path");
XmlSchemaCollection schemColl = new XmlSchemaCollection();
schemColl.Add(null, "yourschemafile.xsd");
XmlValidatingReader valReader = new XmlValidatingReader(xtr);
valReader.ValidationType = ValidationType.Schema;
valReader.Schemas.Add(schemColl);
valReader.ValidationEventHandler += new ValidationEventHandler(valHandler);
// called if errors
while(valReader.Read())
{
// do nothing, just validate
}

Hope this helps.

Orlin
 
Back
Top