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:


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)) {


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.

Introduction to XML_DTD (Previous) XML_Feed_Parser (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.