PHP code example of makinacorpus / simple-xml-reader
1. Go to this page and download the library: Download makinacorpus/simple-xml-reader 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/ */
makinacorpus / simple-xml-reader 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
/* ...your code here... */
return true;
});
$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
/* ...your code here... */
return true;
});
$reader->parse();
$reader->close();