mirror of
https://github.com/php/presentations.git
synced 2026-03-24 15:42:33 +01:00
17 lines
490 B
PHP
17 lines
490 B
PHP
<?php
|
|
$dom = new domDocument();
|
|
$dom->load(dirname(__FILE__) . "/thedata.xml");
|
|
|
|
$root = $dom->documentElement; // <forum>
|
|
foreach ($root->childNodes as $child) {
|
|
if ($child->nodeType == XML_ELEMENT_NODE) { // <item>
|
|
$id = $child->getAttribute("id"); // <item id="value">
|
|
echo "item #{$id}<br />";
|
|
foreach ($child->childNodes as $c2) { // item nodes
|
|
if ($c2->nodeType == XML_ELEMENT_NODE) { // <title>, <link>
|
|
echo "{$c2->nodeName} => {$c2->nodeValue}<br />";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|