Example

Example – Example usage of XML_DTD

Example usage of XML_DTD

You can validate a XML file against a DTD using isValid() like in the example below:

<?php

require_once 'XML/DTD/XmlValidator.php';

$dtd_file realpath('myfile.dtd');
$xml_file realpath('myfile.xml');

$validator = new XML_DTD_XmlValidator();
if (!
$validator->isValid($dtd_file$xml_file)) {
    die(
$validator->getMessage());
}

?>

isValid() will return true when the XML document validates and false otherwise.

This is pretty much the most common usage of XML_DTD and all you need to know to get started.