gacek85 / xml-stream
There is no license information available for the latest version (1.0.0) of this package.
Event driven reader for large XML files
1.0.0
2016-10-27 08:51 UTC
Requires
- php: >=5.5.9
- filp/whoops: ~2.1
- symfony/event-dispatcher: ~3.1.4
Requires (Dev)
- fzaninotto/faker: ~1.6.0
- phpunit/phpunit: ~4.8.0
This package is not auto-updated.
Last update: 2025-01-22 22:21:46 UTC
README
XML Stream
-
Simple library for dealing with large XML lists.
-
Parses XML file chunk by chunk not loading the whole file to the memory and dispatches events informing about found node of given type.
-
The main component is the
Gacek85\XML\Stream
class which wraps all the dependent elemets.
<?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');