hobnob / xml-stream-reader
PHP SAX XML Stream Reader
Installs: 167 019
Dependents: 1
Suggesters: 0
Security: 0
Stars: 46
Watchers: 10
Forks: 16
Open Issues: 2
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 4.*
README
##PHP XML Stream Reader
Reads XML from either a string or a stream, allowing the registration of callbacks when an elemnt is found that matches path.
Installation with Composer
Declare xmlStreamReader as a dependency in your projects composer.json
file:
{ "require": { "hobnob/xml-stream-reader": "1.0.*" } }
Usage Example
<?php $xmlParser = new \Hobnob\XmlStreamReader\Parser(); $xmlParser->registerCallback( '/xml/node/path', function( \Hobnob\XmlStreamReader\Parser $parser, \SimpleXMLElement $node ) { // do stuff with $node } ); $xmlParser->registerCallback( '/xml/node/@attr', function( \Hobnob\XmlStreamReader\Parser $parser, $attrValue ) { // do stuff with $attrValue } ); $xmlParser->parse(fopen('file.xml', 'r'));
Contributors
Licence
© David North
Released under the The MIT License