Rob updated his patch for better XML error handling support in PHP 5.1.
You can now do something like this:
libxml_use_internal_errors(true);
$ret = $dom->load($file);
if (!$ret) {
$errors = libxml_get_errors();
foreach ($errors as $error) {
print $error->message;
if ($error->file) {
print "in file ".$error->file; line:"
print $error->line;
}
print "
";
}
$errors = libxml_get_errors();
}
If you don't set _libxml_use_internalerrors, it does work like in PHP 5.0 and the above code would return nothing.
It doesn't work 100% correctly for XSLT errors right now, but we will fix that until 5.1 comes out ;)
Update: The problem with some XSLT errors are now also fixed. Get the patch from the above location (or wait until it's committed into CVS)
Update 2: It's in CVS now.