Read any XML Schema (XSD) programmatically with PHP.
There are two recommended ways to install the xsd-reader
via Composer:
- using the
composer require
command:
composer require 'goetas-webservices/xsd-reader'
- adding the dependency to your
composer.json
file:
"require": {
..
"goetas-webservices/xsd-reader" : "0.*",
..
}
use Goetas\XML\XSDReader\SchemaReader;
$reader = new SchemaReader();
$schema = $reader->readFile("http://www.example.com/exaple.xsd");
// $schema is instance of Goetas\XML\XSDReader\Schema\Schema;
// Now you can navigate the entire schema structure
foreach ($schema->getSchema() as $innerSchema){
}
foreach ($schema->getTypes() as $type){
}
foreach ($schema->getElements() as $element){
}
foreach ($schema->getGroups() as $group){
}
foreach ($schema->getAttributes() as $attr){
}
foreach ($schema->getAttributeGroups() as $attrGroup){
}
I'm sorry for the terrible english fluency used inside the documentation, I'm trying to improve it. Pull Requests are welcome.