If you are loading xml with the intention of validating it against an internal dtd and you have experienced issues with the validation it could be related to missing LIBXML constants.
I found this post by "aidan at php dot net" in root level dom docs and thought it might be more useful here:
As of PHP 5.1, libxml options may be set using constants rather than the use of proprietary DomDocument properties.
DomDocument->resolveExternals is equivilant to setting
LIBXML_DTDLOAD
LIBXML_DTDATTR
DomDocument->validateOnParse is equivilant to setting
LIBXML_DTDLOAD
LIBXML_DTDVALID
PHP 5.1 users are encouraged to use the new constants.
Example:
<?php
$dom = new DOMDocument;
// Resolve externals
$dom->load($file, LIBXML_DTDLOAD|LIBXML_DTDATTR);
// OR
// Validate against DTD
$dom->load($file, LIBXML_DTDLOAD|LIBXML_DTDVALID);
$dom->validate();
?>
DOMDocument::validate
(No version information available, might be only in CVS)
DOMDocument::validate — Validates the document based on its DTD
Описание
bool DOMDocument::validate
( void
)
Validates the document based on its DTD.
You can also use the validateOnParse property of DOMDocument to make a DTD validation.
Возвращаемые значения
Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки. If the document have no DTD attached, this method will return FALSE.
Примеры
Пример #1 Example of DTD validation
<?php
$dom = new DOMDocument;
$dom->Load('book.xml');
if ($dom->validate()) {
echo "This document is valid!\n";
}
?>
You can also validate your XML file while loading it:
<?php
$dom = new DOMDocument;
$dom->validateOnParse = true;
$dom->Load('book.xml');
?>
DOMDocument::validate
darren at viamedia dot co dot za
05-Aug-2008 04:19
05-Aug-2008 04:19
shinkan at gmail dot com
09-Jul-2008 05:40
09-Jul-2008 05:40
It doesn't seem to support "Internal DTD Declaration" as described by http://www.w3schools.com/dtd/dtd_intro.asp .
