PHP code example of brunty / relax-ng-domdocument

1. Go to this page and download the library: Download brunty/relax-ng-domdocument 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/ */

    

brunty / relax-ng-domdocument example snippets


$document = new \Brunty\DOMDocument;
$document->load('my-file.xml');

$result = $document->relaxNGValidate('my-schema.rng');
// or 
$result = $document->relaxNGValidateSource(file_get_contents('my-schema.rng'));

// $result will be true / false depending on whether the document validated

$document = new \Brunty\DOMDocument;
$document->load('my-invalid-file.xml');

$result = $document->relaxNGValidate('my-schema.rng');

$warnings = $document->getValidationWarnings();