PHP code example of suramon / simple-xml-reader
1. Go to this page and download the library: Download suramon/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/ */
suramon / simple-xml-reader example snippets
$xml = SimpleXmlReader::openFromString('
<root>
<animal type="cat">
<hastail>yes</hastail>
</animal>
<animal type="dog">
<hastail>yes</hastail>
</animal>
<animal type="kakariki">
<hastail>no</hastail>
</animal>
</root>
');
foreach($xml->path('root/animal') as $animal) {
// $animal is of type SimpleXMLElelent
// only the current iterated $animal is in memory, so huge xml files can be read, without much memory consumption
echo "A {$animal->attributes()->type} has a tail? {$animal->hastail}!\n";
}