PHP code example of hobnob / xml-stream-reader

1. Go to this page and download the library: Download hobnob/xml-stream-reader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hobnob / xml-stream-reader example snippets




$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'));