PHP code example of cimus / simplexmlreader
1. Go to this page and download the library: Download cimus/simplexmlreader 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/ */
cimus / simplexmlreader example snippets
$reader = new SimpleXMLReader;
$reader->open("big.xml");
$reader->registerCallback("by-node-name", function($reader) {
$element = $reader->expandSimpleXml(); // copy of the current node as a SimpleXMLElement object
$attributes = $element->attributes(); // read element attributes
/* ... */
});
$reader->registerCallback("/by/xpath/query", function($reader) {
$element = $reader->expandDomDocument(); // copy of the current node as a DOMNode object
$attributes = $element->attributes(); // read element attributes
/* ... */
});
$reader->parse();
$reader->close();