PHP code example of greenter / ubl-validator

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

    

greenter / ubl-validator example snippets


use Greenter\Ubl\UblValidator;

$xml = file_get_contents('20000000001-01-F001-1.xml');

$validator = new UblValidator();

if ($validator->isValid($xml)) {
  echo 'Success!!!';
} else {
  echo $validator->getError();
}

use Greenter\Ubl\UblValidator;
use Greenter\Ubl\Resolver\UblPathResolver;

$ubl = new UblValidator();
$ubl->pathResolver = new UblPathResolver();
$ubl->pathResolver->baseDirectory = './my-ubl-xsd';

echo $ubl->isValid('<Invoice ...>');