can someone help me understand why i get nothing if I change $root from documentElement to getElementsByTagName('tagname')? the result when the function is called but the echo returns empty...
snx!
$dom = new DomDocument();
$dom->load('xml/index.xml');
$root = $dom->documentElement; // <----- arghh!!!
process_children($root);
function process_children($node)
{
$children = $node->childNodes;
foreach ($children as $elem) {
if ($elem->nodeType == XML_TEXT_NODE) {
if (strlen(trim($elem->nodeValue))) {
echo trim($elem->nodeValue)."\n";
}
} else if ($elem->nodeType == XML_ELEMENT_NODE) {
process_children($elem);
}
}
}