Simple xml file:
<?xml version="1.0"?> <dbconfig.xml> <host> <name>localphp4</name> <user> <level>admin</level> <name>root</name> </user> </host> <pass>kjhgkfdh</pass> </dbconfig.xml>
I've got this function this function that gets an element with:
$doc->getElementsByTagname($request) as $element)
That works fine, the first element returned when I request 'host' returns the following with this piece of code:
echo 'This node "'.$node->nodeName.'" is a "type '.$node->nodeType.'" node, child of "' .$node->parentNode->nodeName.'". It\'s value: "'.$node->nodeValue.'".<br />';Prints:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]This node "host" is a "type 1" node, child of "dbconfig.xml". It's value: " localphp4 admin root ".[/quote]
So far so good!
Then I want to loop through the children.
I use $node->childNodes; in a loop to try and get elements "name" and "user".
However it only loops once (as confirmed by count($node->childNodes) resulting in "1"), and claims this only child is of type DOMText (and empty):
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]This node "#text" is a "type 3" node, child of "host". It's value: " ".[/quote]
Shoot me, I don't get it.
Oh, I forgot to mention that I did check for whitespaces, as I read somewhere they can cause problems..