Validate an XML Document Against a Schema
You want to ensure that an XML document conforms to an XML schema.
Use XmlValidatingReader and handle the ValidationEventHandler event.
An XML schema defines the rules that a given type of XML document must follow. The schema includes rules that define
The elements and attributes that can appear in a document.
The data types for elements and attributes.
The structure of a document, including what elements are children of other elements.
The order and number of child elements that appear in a document.
Whether elements are empty, can include text, or require fixed values.
XML schema documents are beyond the scope of this chapter, but much can be learned from a simple example. Essentially, ...