loadXML($xmlString); $prevValue = libxml_use_internal_errors(true); libxml_clear_errors(); $isValid = $doc->schemaValidate($xsdFilename); if (!$isValid) { $errors = libxml_get_errors(); libxml_clear_errors(); libxml_use_internal_errors($prevValue); throw new XsdValidationError($errors); } libxml_use_internal_errors($prevValue); } }