This documentation is archived and is not being maintained.

XDocument.Validate Method

Visual Studio 2008

Validates that an XDocument, an XElement, or an XAttribute conforms to an XSD in an XmlSchemaSet.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

Public Extension Method Validate(XmlSchemaSet, ValidationEventHandler) This method validates that an XDocument conforms to an XSD in an XmlSchemaSet. (Defined by Extensions.)
Public Extension Method Validate(XmlSchemaSet, ValidationEventHandler, Boolean) Validates that an XDocument conforms to an XSD in an XmlSchemaSet, optionally populating the XML tree with the post-schema-validation infoset (PSVI). (Defined by Extensions.)

These methods use an underlying XmlReader to validate the XML tree against an XSD.

Validation error and warning messages are handled using the ValidationEventHandler delegate. If no event handler is provided to these methods, validation errors are exposed as an XmlSchemaValidationException. Validation warnings do not cause an XmlSchemaValidationException to be thrown.

Some of these extension methods optionally allow population of the post-schema-validation infoset (PSVI).