XML and schema

O

Orlin Popov

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
 
S

Scott Mitchell [MVP]

S

Scott Mitchell [MVP]

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top