1. Go to this page and download the library: Download benmorel/xml-streamer 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/ */
benmorel / xml-streamer example snippets
use BenMorel\XMLStreamer\XMLStreamer;
$streamer = new XMLStreamer('feed', 'products', 'product');
foreach ($streamer->stream('product-feed.xml') as $product) {
/** @var DOMElement $product */
echo $product->getElementsByTagName('name')->item(0)->textContent; // foo, ..., bar
}
foreach ($streamer->stream('product-feed.xml') as $product) {
/** @var DOMElement $product */
$document = new \DOMDocument();
$document->appendChild($product);
$element = simplexml_import_dom($product);
echo $element->name; // foo, ..., bar
}