/** * Creates a child node of the current element. * $content is optional. * * @access public * @param string $name * @param string $content * @return resource * */ function &addChild($name, $content = '') { // returns XMLNode object, stores internal pointer $count = 0; foreach ($this->children as $child) { if ($name == $child->name) { $count++; } } $obj = new XMLNode($name, $content, $count, $this); if ($this->propagateCallback) { if ($this->callbackEnd) { $obj->setCallback($this->callbackStart, $this->callbackEnd, $this->callbackObject); } else { $obj->setCallback($this->callbackStart, $this->callbackObject); } $obj->propagateCallback = true; } $this->children[] = $obj; if (!isset($this->{'_' . $obj->name})) { $this->{'_' . $obj->name} =& $this->children[count($this->children) - 1]; } elseif (!is_array($this->{'_' . $obj->name})) { $tmp =& $this->{'_' . $obj->name}; unset($this->{'_' . $obj->name}); $this->{'_' . $obj->name} = array(); $this->{'_' . $obj->name}[] =& $tmp; $this->{'_' . $obj->name}[] =& $this->children[count($this->children) - 1]; } else { $this->{'_' . $obj->name}[] =& $this->children[count($this->children) - 1]; } return $this->children[count($this->children) - 1]; }