I am going through an XML file and trying to get the name of a child (or children) node(s) but I'm missing something. Even though there are child nodes, my foreach loop acts as if there is not.
$pos = $node->sense->pos;
foreach ($pos->children() as $child) {
echo "I never get here";
echo $child->getName() . "\n";
}
echo "but the node has children---<br>";
print_r($pos);
The output looks like this
but the node has children---
SimpleXMLElement Object
(
[n] => SimpleXMLElement Object
(
)
)
but the node has children---
SimpleXMLElement Object
(
[adj-na] => SimpleXMLElement Object
(
)
)
but the node has children---
SimpleXMLElement Object
(
[pn] => SimpleXMLElement Object
(
)
)
Any idea why the foreach doesn't go through the children or how I can get the name(s) of the child node?