1. Go to this page and download the library: Download hyperized/xml-validator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hyperized / xml-validator example snippets
use Hyperized\Xml\Exceptions\InvalidXml;
use Hyperized\Xml\Exceptions\XmlValidatorException;
use Hyperized\Xml\Validator;
$validator = new Validator();
try {
$validator->validateXMLFile('/path/to/document.xml', '/path/to/schema.xsd');
} catch (InvalidXml $exception) {
// Malformed, or rejected by the schema. Line and column survive.
foreach ($exception->getErrors() as $error) {
printf("line %d column %d: %s\n", $error->line, $error->column, trim($error->message));
}
} catch (XmlValidatorException $exception) {
// Missing, unreadable or empty file.
printf("%s: %s\n", $exception::class, $exception->getMessage());
}