how to validate a xml file against a xsd? there is domdocument::schemaValidate() but It does not tell where are the errors. is there any class for that? does it have any worth m
This is a complete code snippet for displaying xsd validation errors:
$xml = ' ';
$xsd = '/path/to/xsd';
// needed for getting errors
libxml_use_internal_errors(true);
$domDocument= new DOMDocument();
$domDocument->loadXML($xml);
if (!$domDocument->schemaValidate($xsd)) {
$errors = libxml_get_errors();
foreach ($errors as $error) {
print_r($error);
}
libxml_clear_errors();
}