Hello everybody, I have XML file like this :
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
And i code in my php page:
<? php
$xmlDoc = new DOMDocument();
$xmlDoc->load("note.xml");
$x = $xmlDoc->documentElement;
foreach ($x->childNodes AS $item)
{
print $item->nodeName . " = " . $item->nodeValue . "<br />";
}
?>
The output of the code above is:
#text =
to = Tove
#text =
from = Jani
#text =
heading = Reminder
#text =
body = Don't forget me this weekend!
#text =
I known that when XML generates, it often contains white-spaces between the nodes. But Anybody can help me loop through all elements of the element of XML bypass white-spaces between the nodes. I mean loop through only all real elements of the element. Pls help me.