Validate the document based on its DTD in PHP

Description

The following code shows how to validate the document based on its DTD.

Example


// w w  w.java  2s. co  m
<?php
$dom = new DOMDocument;
$dom->Load('test.xml');
if ($dom->validate()) {
    echo "This document is valid!\n";
}
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    XML »




DOM
SimpleXML
SimpleXMLElement
XML Parser