PHP code example of gacek85 / xml-stream

1. Go to this page and download the library: Download gacek85/xml-stream 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/ */

    

gacek85 / xml-stream example snippets

 php


use Gacek85\XML\Chunk\Provider as ChunkProvider;
use Gacek85\XML\Node\Detector as NodeDetector;
use Gacek85\XML\Node\Event\Event as NodeEvent;
use Gacek85\XML\Node\Event\EventInterface;
use Gacek85\XML\Node\Event\Feature\DOMElementProvider;
use Gacek85\XML\Node\Event\Provider as EventProvider;
use Gacek85\XML\Stream;
use Symfony\Component\EventDispatcher\EventDispatcher;

$eventProvider = (new EventProvider())
                    ->addFeatureProvider(new DOMElementProvider());

$stream = new Stream(
            new EventDispatcher(),
            new ChunkProvider('/path/to/file.xml', 1024),	// 2nd param is chunk length
            new NodeDetector(),
            $eventProvider
);

$stream
		->getDispatcher()
        ->addListener(EventInterface::NAME, function (NodeEvent $ev) {
			// Do your stuff here
		});

$stream->read('listNodeName');