seromenho/xml-validator
最新稳定版本:v1.0
Composer 安装命令:
composer require seromenho/xml-validator
包简介
Validates your XML against a xsd schema file.
关键字:
README 文档
README
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
<?php require "./vendor/autoload.php"; use XmlValidator\XmlValidator; $xml = "<sample>my xml string</sample>"; $xsd = "path_to_xsd_file.xsd"; // Validate $xmlValidator = new XmlValidator($xml, $xsd); 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.
统计信息
- 总下载量: 207.97k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-08