name = $name; } function getName() { return $this->name; } function getChildByPath($pathArray) { if (count($pathArray) > 0) { $removedElement = array_shift($pathArray); $match = $this->getChildByName($removedElement); if ($match === false) throw new Exception("PathElement $removedElement couldn't be found"); else { return $match->getChildByPath($pathArray); } } else { return $this; } } function output($level = 0) { echo str_repeat("\t", $level); echo $this->getName()."\n"; foreach ($this->children as $key => $child) { $child->output($level +1); } } } ?>