System.Xml.XmlReaderSettings.ValidationEventHandler Event

Occurs when the reader encounters validation errors.

Syntax

public event System.Xml.Schema.ValidationEventHandler ValidationEventHandler

Remarks

These events occur while reading an XML instance document if the XmlReaderSettings.ValidationType is set to either ValidationType.DTD or ValidationType.Schema. If the System.Xml.Schema.XmlSchemaValidationFlags.ReportValidationWarnings setting has been enabled on the XmlReaderSettings.ValidationFlags property these events also occur when any validation warnings are encountered.

If the reader is configured for validation and no validation event handler has been set, an System.Xml.Schema.XmlSchemaValidationException is thrown for all validation errors. (Validation warnings do not cause an System.Xml.Schema.XmlSchemaValidationException to be thrown).

Note:

Validation error messages may expose sensitive content model information. Validation error and warning messages are handled using the System.Xml.Schema.ValidationEventHandler delegate, or are exposed as an System.Xml.Schema.XmlSchemaValidationException if no event handler is provided to the System.Xml.XmlReaderSettings object (validation warnings do not cause an System.Xml.Schema.XmlSchemaValidationException to be thrown). This content model information should not be exposed in untrusted scenarios. Validation warning messages are suppressed by default and can be reported by setting the System.Xml.Schema.XmlSchemaValidationFlags.ReportValidationWarnings flag.

The System.Xml.Schema.XmlSchemaException.SourceUri property of an System.Xml.Schema.XmlSchemaValidationException returns the URI path to the schema file that caused the exception. The System.Xml.Schema.XmlSchemaException.SourceUri property should not be exposed in untrusted scenarios.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0