PHP code example of metasyntactical / xml-tools

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

    

metasyntactical / xml-tools example snippets



use MetaSyntactical\Xml\Reader\XmlStreamReader;
use MetaSyntactical\Xml\Reader\XmlPath;
use DOMElement;
use MetaSyntactical\Xml\XmlStream\FileXmlStream;

$reader = new XmlStreamReader();

// register callables
$reader->registerCallback(
    new XmlPath("/example/node"),
    function (DOMElement $element) {
        echo "Match";
    }
}

// parse file
$reader->parse(new FileXmlStream("/path/to/xml/file.xml");