<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting tonight!</body>
</note>
<?php
$xmlDoc = new DOMDocument();
$xmlDoc -> load("test.xml");
$x = $xmlDoc->documentElement;
foreach($x->childNodes as $item)
{
print $item -> nodeName . " = " . $item->nodeValue . "<br/>";
}
?>
Output:
#text =
to = George
#text =
from = John
#text =
heading = Reminder
#text =
body = Don't forget the meeting tonight!
#text =