function &addChild($tag, &$offset = null)
{
#php5e
if (is_array($tag)) {
$tag = new $this->childClass($tag, $this);
} elseif (is_string($tag)) {
$nodes = $this->createNodes($tag);
$tag = array_shift($nodes);
if ($tag && $tag->parent !== $this) {
$index = false;
$tag->changeParent($this, $index);
}
} elseif (is_object($tag) && $tag->parent !== $this) {
$index = false;
//Needs to be passed by ref
$tag->changeParent($this, $index);
}
if (is_int($offset) && $offset < count($this->children) && $offset !== -1) {
if ($offset < 0) {
$offset += count($this->children);
}
array_splice($this->children, $offset++, 0, array(&$tag));
} else {
$this->children[] =& $tag;
}
return $tag;
}