Validation of XML with XmlValidatingReader
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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 Microsoft XML Core Services (MSXML) Schema specification for XML-Data Reduced (XDR) schemas, and the W3C XML Schema Recommendation for XML Schema definition language (XSD) schemas.

NoteNote:

The XmlValidatingReader class is obsolete in the .NET Framework version 2.0. You can create a validating XmlReader instance using the XmlReaderSettings class and the Create method. For more information, see Validating XML Data with XmlReader.

If you had been using the XmlValidatingReader class to expand entities, this functionality has been added to the XmlTextReader class.

The XmlValidatingReader.Schemas property provides the reader with access to schemas loaded into the built-in 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 XmlValidatingReader.XmlResolver property specifies the XmlResolver object used to resolve external entities (for example, document type definition (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 XmlValidatingReader.BaseURI property. For more information about the XmlResolver, see Resolving Resources Using the XmlResolver.

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 DTD validation.

Validation against XDR with the XmlValidatingReader

Describes the implementation of 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 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.

Reading XML with the XmlReader

Describes how the XmlReader class provides a non-cached, forward only, read-only access to XML data over an XML stream.

Show:
© 2016 Microsoft