Overview
This example shows how to do very basic validation of an XML document.

Well formedness
The DOM parser automatically tests for well-formedness when loading the file (row 10). The value that is returned from the load method is true if the file was well-formed and false if not.

Validation
Validation of the file using the DTD linked by the XML file (if such a link exists) is performed with the validate method. The value returned is true if the file is valid and false if not.

Validation is as simple as this in the simplest case. However we do not get very detailed information abou why validation or well-formedness has failed.

Web Page Output: