2017 © Pedro Peláez
 

library xml-validator

Validates your XML against a xsd schema.

image

vrbata/xml-validator

Validates your XML against a xsd schema.

  • Thursday, April 5, 2018
  • by vrbata
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,479 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 3 Versions
  • 653 % Grown

The README.md

PHP Xml validator

Build Status Packagist, (*1)

Validate Xml against a xsd schema., (*2)

Installation

Library

$ git clone https://github.com/vrbata/XmlValidator.git

Composer

$ composer require vrbata/xml-validator:dev-master

Usage

<?php
require "./vendor/autoload.php";
use XmlValidator\XmlValidator;

$xml = "<sample>my xml string</sample>";
$xsd = "path_to_xsd.xsd";

// Validate based on xsd file
$xmlValidator = new XmlValidator($xml, $xsd, XsdSource::FILE);
try{
    $xmlValidator->validate($xml,$xsd);

    // Check if is valid
    if(!$xmlValidator->isValid()){

        // Do whatever with the errors.
        foreach ($xmlValidator->errors as $error) {
            /*echo sprintf('[%s %s] %s (in %s - line %d, column %d)',
                $error->level, $error->code, $error->message, 
                $error->file, $error->line, $error->column
            ); */
        }
    }
} catch (\InvalidArgumentException $e){
    // catch InvalidArgumentException
}

// Validate based on xsd as string
$xmlValidator = new XmlValidator($xml, $xsd, XsdSource::STRING);
try{
    $xmlValidator->validate($xml,$xsd);

    // Check if is valid
    if(!$xmlValidator->isValid()){

        // Do whatever with the errors.
        foreach ($xmlValidator->errors as $error) {
            /*echo sprintf('[%s %s] %s (in %s - line %d, column %d)',
                $error->level, $error->code, $error->message, 
                $error->file, $error->line, $error->column
            ); */
        }
    }
} catch (\InvalidArgumentException $e){
    // catch InvalidArgumentException
}

Based on XmlUtils from Symfony config component., (*3)

The Versions

05/04 2018

dev-master

9999999-dev http://github.com/vrbata/XmlValidator

Validates your XML against a xsd schema.

  Sources   Download

MIT

The Requires

  • php >=7.2.0

 

The Development Requires

by Josef Vrbata

xml xsd psr-4 xml validator

05/04 2018

v2.0.0

2.0.0.0 http://github.com/vrbata/XmlValidator

Validates your XML against a xsd schema.

  Sources   Download

MIT

The Requires

  • php >=7.2.0

 

The Development Requires

by Josef Vrbata

xml xsd psr-4 xml validator

24/06 2015

v1.0.0

1.0.0.0 http://github.com/seromenho/XmlValidator

Validates your XML against a xsd schema file.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

xml xsd psr-4 xml validator