It can validate an XML document as it reads and parses the document.In this example, we demonstrate how to activate such validation.Xml Schema Set schemas = new Xml Schema Set(); schemas. Write Line("Attempting to validate"); XDocument cust Ord Doc = XDocument.
The Add method receives as arguments a namespace URI that identifies the schema ( and the name and location of the schema file (in the current directory).
Create and set the properties of an Xml Reader Settings object.
Specifically, after successful validation, schema defaults are applied, text values are converted to atomic values as necessary, and type information is associated with validated information items.
The result is a previously un-typed XML sub-tree in the Xml Document replaced with a typed sub-tree.
Validate(schemas, (o, e) = The following example validates that the XML document from Sample XML File: Customers and Orders (LINQ to XML) is valid per the schema from Sample XSD File: Customers and Orders. This example uses the following XML document: Sample XML File: Customers and Orders (LINQ to XML).