Xml Schema Set schemas = new Xml Schema Set(); schemas. Write Line("Attempting to validate"); XDocument cust Ord Doc = XDocument. Load("Customers Orders.xml"); bool errors = false; cust Ord Doc.
This example uses the following XSD schema: Sample XSD File: Customers and Orders. Write Line(); // Modify the source document so that it will not validate. In this case, the XML Schema is to be found in the same folder as the XML Document.It is also possible to specify an absolute location, but beware that you must use URL syntax, not Path syntax.The Validation Type property of the Xml Reader Settings object is set to to enforce validation of the XML document by the Create method of the Xml Reader object.A Validation Event Handler is added to the Xml Reader Settings object to handle any Warning or Error events raised by errors found during the validation process of both the XML document and the schema.[!CODE [XSDInference Examples#6](../Code Snippet/VS_Snippets_Data/XSDInference Examples#6)]In the code example that follows, the schema above is added to the Xml Schema Set Schemas property of the Xml Reader Settings object.