Fastest handling of huge XML data.

1.0.0 2022-05-23 07:27 UTC

This package is auto-updated.

Last update: 2024-05-23 11:50:28 UTC


PHP from Packagist Codacy Badge Latest Stable Version Total Downloads License


Fastest handling of huge XML data.

The Bit&Black XML Processor is up to 20 times faster in parsing huge xml data. This is because it doesn't make use of foreach to handle XML nodes. Instead, the processor uses a while loop and a copy of the DOMElements.


This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/xmlprocessor.


Set up the processor with your xml data:


use DOMDocument;
use BitAndBlack\XML\XMLProcessor;

$domDocument = new DOMDocument();

$xmlProcessor = new XMLProcessor($domDocument);

Use eachElement() now instead of foreach:


//$nodes = $domDocument->getElementsByTagName('some_node'):
//foreach ($nodes as $key => $node) {
//    var_dump('Found at position ' . $key . ' node with id ' . $node->getAttribute('id'));

    static function(DOMDocument $domDocument) {
        return $domDocument->getElementsByTagName('some_node');
    static function(DOMNode $node, int $key) {
        var_dump('Found at position ' . $key . ' node with id ' . $node->getAttribute('id'));

The first attribute is a function where you can set up the statement with whom you can select the nodes you want to.

The second attribute is a callback function which is called for every processed item.

eachElement() makes a clone of the DOM to reach a fast processing so modifying the original DOM at the same time will not target the processed data.


If you have questions feel free to contact us under

Further information about Bit&Black can be found under