PHP code example of ottosmops / xmlvalidator

1. Go to this page and download the library: Download ottosmops/xmlvalidator 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/ */

    

ottosmops / xmlvalidator example snippets




ttosmops\XmlValidator\XmlValidator;

class test {
    public static function index() {
        $option = ['file'   => 'tests/data/valid/mets_001.xml',
                    'ns'     => 'mets',
                    'nsuri'  => 'https://www.loc.gov/METS/',
                    'root'   => 'mets',
                    'schema' => 'https://www.loc.gov/standards/mets/mets.xsd'];

        $validator = new XmlValidator($option);
        if (!$validator->validate()) {
            print("validated mets: is not valid".PHP_EOL);
            print($validator->getErrors());
        } else {
            print("validated mets: is valid".PHP_EOL);
        }
    }
}

test::index();