Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XmlDocument.Validate Method (ValidationEventHandler, XmlNode)

Note: This method is new in the .NET Framework version 2.0.

Validates the XmlNode object specified against the XML Schema Definition Language (XSD) schemas in the Schemas property.

Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)

public void Validate (
	ValidationEventHandler validationEventHandler,
	XmlNode nodeToValidate
)
public void Validate (
	ValidationEventHandler validationEventHandler, 
	XmlNode nodeToValidate
)
public function Validate (
	validationEventHandler : ValidationEventHandler, 
	nodeToValidate : XmlNode
)

Parameters

validationEventHandler

The ValidationEventHandler object that receives information about schema validation warnings and errors.

nodeToValidate

The XmlNode object created from an XmlDocument to validate.

Exception typeCondition

ArgumentException

The XmlNode object parameter was not created from an XmlDocument.

InvalidOperationException

The XmlNode object parameter is not an element, attribute, document fragment, or the root node.

XmlSchemaValidationException

A schema validation event occurred and no ValidationEventHandler object was specified.

The Validate method validates the XML data in the XmlNode object against the schemas contained in the Schemas property. The Validate method performs infoset augmentation. Specifically, after successful validation, schema defaults are applied, text values are converted to atomic values as necessary, and type information is associated with validated information items. The result is a previously un-typed XML sub-tree in the XmlDocument replaced with a typed sub-tree.

The following are important notes to consider when using the Validate method.

  • Schema location hints like xsi:schemaLocation or xsi:noNamespaceSchemaLocation are ignored.

  • Inline schemas are ignored.

  • If schema validation errors occur during validation the XmlDocument becomes partially validated with some nodes with correct type information and some without.

If the XmlDocument is positioned on the root node, the validation process includes checking of uniqueness and reference constraints (xs:ID, xs:IDREF, xs:key, xs:keyref, and xs:unique); otherwise uniqueness and reference constraints are omitted.

For an example of the Validate method, see the Validate method.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft