The text reader is used to walk through the nodes of the document whereas the validating reader examines and validates each single piece of XML according to the requested validation type.Although the Xml Validating Reader class inherits from the base class Xml Reader, it really implements internally only a very small set of all the required functionalities.

Much of this post is based on the OASIS specification (C14N), which describes a variety of ways to normalize an XML tree, including through the use of PSVI. Deep Equals reports that equivalent XML trees are unequal.

In the following example, the two trees have exactly the same content.

An XML validating reader, in fact, cannot be directly initialized from a file.

The following is the most commonly used constructor.

Schema namespace contains extension methods that make it easy to validate an XML tree against an XML Schema Definition Language (XSD) file.

This example uses the following XSD schema: Sample XSD File: Customers and Orders.

The W3C XML specification states that a program should stop processing an XML document if it finds an error.

The reason is that XML software should be small, fast, and compatible.

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).

After the change, orders will then refer to a customer that does not exist, so the XML document will no longer validate.

First of all, thank you very much for your excellent article and example. However, I have been struggling on how to use this exact example to parse one level deeper using a second nested foreach loop within the Student Node List. So, to be more specific, in your example, how would you continue parsing the following XML with the following conditions: 1) each Student may have one or more Courses as children nodes to each Student 2) each Student's Course list contains a varying and unknown content (actual course represented in the Inner Text) Your XML sample might look like this: APPROACH TRIED: I've tried so far is to nest a second foreach loop within the original Student Node Listforeach loop (called Course Node List).