Start Validating an xml file

Validating an xml file

To validate the XML in the DOM, you can validate the XML as it is loaded into the DOM by passing a schema-validating Xml Reader to the Load method of the Xml Document class, or validate a previously unvalidated XML document in the DOM using the Validate method of the Xml Document class.

What should i add in order to validate an xml file whose schema is specified in multiple files?

The code does validate the xml that have only one schema file.

Although a full treatment of XML Schema is beyond the scope of this tutorial, this section shows you the steps you take to validate an XML document using an XML Schema definition.

(To learn more about XML Schema, you can review the online tutorial, XML Schema Part 0: Primer.

If a Validation Event Handler was assigned to the Xml Reader Settings instance, or passed to the Validate method of the Xml Document class, the Validation Event Handler will handle schema validation errors; otherwise an Xml Schema Validation Exception is raised when a schema validation error is encountered.

The XML data is loaded into the DOM despite schema validation errors unless your Validation Event Handler raises an exception to stop the process.

Invalid modifications are then made to the XML document, and the document is then revalidated, causing schema validation errors.

XML schema validation errors are reported when validating XML data loaded in the DOM.

Additionally, another exception occurred while executing the custom error page for the first exception.

This section looks at the process of XML Schema validation.

At the end of this section, you will also learn how to use an XML Schema definition to validate a document that contains elements from multiple namespaces.