Skip to content

Latest commit

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

PHP Xml validator

Build StatusPackagist

Validate Xml against a xsd schema file.

Installation

Library

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

Composer

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

Usage

<?phprequire"./vendor/autoload.php";
useXmlValidator\XmlValidator;
$xml = "<sample>my xml string</sample>";
$xsd = "path_to_xsd_file.xsd";
// Validate$xmlValidator = newXmlValidator($xml, $xsd);
try{
$xmlValidator->validate($xml,$xsd);
// Check if is validif(!$xmlValidator->isValid()){
// Do whatever with the errors.foreach ($xmlValidator->errorsas$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.

About

Validates XML against a schema.

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages