Find the children of a node in PHP
Description
The following code shows how to find the children of a node.
Example
//ww w. j a va2s . co m
<?php
$note=<<<XML
<note>
<to>Work</to>
<from>Home</from>
<heading>Reminder</heading>
<body>This is a message.</body>
</note>
XML;
$xml=simplexml_load_string($note);
foreach ($xml->children() as $child){
echo "Child node: " . $child . "<br>";
}
?>
The code above generates the following result.