Validation of XML with XmlValidatingReader
The XmlValidatingReader class, an implementation of the XmlReader class, provides support for XML validation. You can use the XmlValidatingReader to validate XML documents and XML fragments. This class implements the validity constraints defined in the World Wide Web Consortium (W3C) Extensible Markup Language (XML) 1.0 Recommendation for document type definitions (DTDs), the MSXML Schema specification for XML-Data Reduced (XDR) schemas, and the W3C XML Schema Recommendation for XML Schema definition language (XSD) schemas.
The Schemas property of XmlValidatingReader provides the reader with access to schemas loaded into the built XmlSchemaCollection. Because these schemas are cached, the reader can validate a schema without having to reload it each time. The use of schemas cached in memory significantly improves performance.
The XmlResolver property of XmlValidatingReader is used to resolve external entities (for example, DTD and schema locations). If you have a custom XmlResolver or if you are accessing a network resource that requires credentials, use this property to specify which XmlResolver to use. To resolve external references in which an XmlResolver is not specified, the reader uses a default XmlUrlResolver. The XmlUrlResolver class resolves file and HTTP protocols.
The XmlResolver is also used to process xs:include and xs:import elements in XML Schemas. If xs:include or xs:import elements have a relative path, the XmlValidatingReader resolves the relative path using the BaseURI property of the XmlValidatingReader. For more information about the XmlResolver, see Resolving Resources Using the XmlResolver.
In This Section
- Validation Types of the XmlValidatingReader
- Describes the validation type properties you can set to determine what type of validation will occur.
- XmlValidatingReader Validation Event Handler Callback
- Describes the use of the ValidationEventHandler event for receiving information about validation errors.
- Validation against DTD with the XmlValidatingReader
- Describes the implementation of document type definition (DTD) validation.
- Validation against XDR with the XmlValidatingReader
- Describes the implementation of XML-Data Reduced (XDR) schema validation.
- Validation with an Inline XDR Schema
- Provides an example of using the XmlValidatingReader to validate against an inline XDR schema.
- Validation against XML Schema (XSD) with the XmlValidatingReader
- Describes the implementation of XML Schema definition language (XSD) schema validation.
- Validation with an Inline XML Schema (XSD)
- Provides an example of using the XmlValidatingReader to validate against an inline XML Schema.
- XML Schema (XSD) Validation with Multiple Schemas
- Provides an example of the validation of XML fragments against multiple schema sources.
- Reading XML Fragments with the XmlValidatingReader
- Describes the use of XmlValidatingReader for reading XML fragments.
- Validation of XML with Schemas
- Describes the document type definition (DTD), XML-Data Reduced (XDR) schema, and XML Schema definition language (XSD) validation available in the .NET Framework.
- XmlSchemaCollection as a Schema Cache
- Explains how to load schemas to a cached collection for use in validation.