Hi
Some maybe already recognized it, for the others: There's DTD-Validation
in domxml available now.
Just for the record, some examples how to use it.
$xmldoc = xmldocfile("xhtml1.xhtml",DOMXML_LOAD_PARSING,$error);
will parse the file as before, but gives you more meaningfull
errormessages in the array $error. For example:
$error = Array
(
[0] => Array
(
[errormessage] => Entity 'copy' not defined
[nodename] => p
[line] => 102
[col] => 60
[directory] => /usr/local/apache/htdocs/test
[file] => xhtml1.xhtml
)
$xmldoc = xmldocfile("xhtml1.xhtml",DOMXML_LOAD_VALIDATING,$error);
will validate against the DTD in the xml Document. THe error-messages are
in $error as well ->
$error = Array
(
[0] => Array
(
[nodename] => head
[line] => 8
[col] => 31
[directory] => /usr/local/apache/htdocs/test
[file] => xhtml1.xhtml
[errormessage] => No declaration for attribute blbla on
element link
)
The same principle works with domxml_open_mem() as well.
Furthermore, there's a $xmldoc->validate([$error]) method. It returns true
or false on validating and some errormessages in the array $error. The
problem here is, that i was not able to get more meaningful messages than
$error = Array
(
[0] => Array
(
[errormessage] => No declaration for attribute blbla on
element link
)
therefore it's maybe better to do the validating on parsing, 'cause then
you can get line and cole number for locating the error.
that's it for the moment.
chregu
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php