Speed up development with full-stack environments for every branch.

Learn More

Iterate and display a xml document [XMLReader and PHP]

108 Runs 471 Views 170 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php
/*
 * PHP XMLReader - Iterate and display a xml document
 */

$reader = new XMLReader();
$reader->open('test.xml');

while ($reader->read()) {
    if ($reader->nodeType == XMLReader::ELEMENT && $reader->depth) {
        $exp = $reader->expand();
        echo "<b>" . $exp->nodeName . " : </b>" . $exp->nodeValue . "<br />";
    }
}
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).