Simplexml will not do this, but DomDocument can do it. Also, xml should have some link to the DTD file.
<?php
$dom = new DOMDocument;
$dom->Load('book.xml');
if ($dom->validate()) {
echo "This document is valid!\n";
}
?>
you can look at question sitelinks
source
share