Hi,
Why, when using the domxml parser can I not retrieve an element as follows:
$details = $this->getChild("name")->getChild("details");
instead I have to do this :
$name = $this->getChild("name");
$details = $this->getChild("details");
what am I doing wrong ?
the code is below:
class parentxmltest
{
function getChild($name,$key=NULL) {
if ($key==NULL) $key=$this->root();
$nodes = $key->children();
while($node = array_shift($nodes)) {
if ($node->name == $name) {
break;
}
}
return $node;
}
}
class childxmltest extends parentxmltest
{
var $xml;
function childxmltest($xml) {
$this->xml = $xml
childxmltesst::loadXML()
}
function loadXML() {
...
...
get root node "employee"
$employee = $doc->root();
why doesn't this work ?
$details = $this->getChild("name")->getChild("details");
I have to do this instead
which is very tedious
#$name = $this->getChild("name");
#$details = $this->getChild("details");
}
}
the xml document is in the following format
employee
-name
-details
|
-position
-contract
and I start things off as follows:
$test = new childxmltest($xmlstr