I'm following this tutorial:
Looping through XML part is problematic. PHP for some reason treats DOM object as an array. Furthermore, var_dump returns nothing about object attributes except length, but program output looks like it came out of nowhere. Can foreach loop through object somehow ? And if it does, where are these attributes contained (node name and node value) because var_dump is not showing them ?
$xml=new DOMDocument ();
$xml->load('note.xml');
$array_of_nodes=$xml->documentElement->childNodes;
var_dump($array_of_nodes);
foreach($array_of_nodes as $item) {
echo $item->nodeName." ".$item->nodeValue."<br>";
}
Var dump function returns this:
object(DOMNodeList)#3 (1) { ["length"]=> int(9) } #text
But the executed code look like this:
text =
to = Tove
text =
from = Jani
text =
heading = Reminder
text =
body = Don't forget me this weekend!
text =