dev-master
9999999-devA simple PHP XML validator
MIT
The Requires
- php >=7.1
The Development Requires
by Gerben Geijteman
xml validator
A simple PHP XML validator
A simple PHP XML validator., (*2)
```shell script composer require hyperized/xml-validator, (*3)
## Usage ```php <?php namespace Hyperized\Xml; require __DIR__ . '/vendor/autoload.php'; $xmlString = file_get_contents(__DIR__ . '/tests/files/correct.xml'); $dirtyXMLString = file_get_contents(__DIR__ . '/tests/files/incorrect.xml'); $xmlFile = __DIR__ . '/tests/files/correct.xml'; $xsdFile = __DIR__ . '/tests/files/simple.xsd'; $validator = new Validator(); // String validation print_r($validator->isXMLStringValid($xmlString)); // 1 print_r($validator->isXMLStringValid($xmlString, $xsdFile)); // 1 // File validation print_r($validator->isXMLFileValid($xmlFile)); // 1 print_r($validator->isXMLFileValid($xmlFile, $xsdFile)); // 1 // Error handling try { $validator->isXMLStringValid($dirtyXMLString, $xsdFile); } catch (Exceptions\InvalidXmlException $exception) { print_r($exception->getMessage()); // xmlParseEntityRef: no name\n The document has no document element. }
You're free to use this package, but if it makes it to your production environment you are required to buy the world a tree., (*4)
It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you support this package and contribute to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats., (*5)
You can buy trees here offset.earth/treeware, (*6)
Read more about Treeware at treeware.earth, (*7)
A simple PHP XML validator
MIT
xml validator