You can ensure the validation of XML documents by using the Xml Validating-Reader class. The Xml Validating Reader class is a derived class of the Xml Reader class and adds validation support to the Xml Text Reader class. None Creates an XML 1.0-compliant nonvalidating parser, parses the XML without performing any validation, does not throw any exception or supply any information, and expands the default attributes and entities in the DTD. Xml Validating Reader parses a string as an XML fragment.

You should also ensure that the XML document matches its schema or conforms to the constraints defined by its DTD.

For example, if you specify the age of an employee to be between 18 and 60 years in the schema of your XML document, the actual data in your XML document must conform to the condition or it will be considered invalid.

When you load Xml Validating Reader to validate an XML document against its DTD, Xml Validating Reader uses the DTD defined in the DOCTYPE declaration of the XML document. Table 6.10 Parsing of XML Fragments In the previous lesson, you learned how to validate an XML document using XML Schema.

The following code displays how to create an Xml Validating Reader class that takes an XML document as the input and validates it against an external DTD file, You also learned about the Xml Validation Reader class.

You should ensure that the XML document that you create is well formed.

Any XML parser can read a well-formed XML document; therefore, you can display the XML document anywhere.

The XDR schema can be used to create XML views of relational data.

For example, Microsoft SQL Server 2000 allows you to obtain the result of a query in the form of an XML document, which can be validated against an XDR schema.

If Xml Validating Reader finds a DTD or XML Schema, Xml Exception is thrown indicating mixed validation types.

If you set the Validation Type property to Schema, Xml Validating Reader validates the document according to the XML Schema, including inline schemas.

To validate an XML document, you first load Xml Validating Reader for an XML document by using the Load method.