PHP code example of kherge / xml

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

    

kherge / xml example snippets




use KHerGe\XML\FileReaderFactory;

// Open an existing and very large XML file.
$reader = (new FileReaderFactory())->open('/path/to/large.xml');

// Iterate through each node in the XML document.
foreach ($reader as $path => $node) {
    if ($node->isElement()) {
        echo $path, ' = ', $node->getValue(), "\n";
    }
}



$reader = new XMLReader();
$reader->open('/path/to/large.xml');

while ($reader->read());



use KHerGe\XML\FileReaderFactory;

$reader = (new FileReaderFactory())->open('/path/to/large.xml');

foreach ($reader as $element);