Replaces the current element with the element specified

@param SimpleXMLExtended $child The element to replace me

@return this
432298
public function replace(SimpleXMLExtended $child)
    {
        $node1 = dom_import_simplexml($this);
        $dom_sxe = dom_import_simplexml($child);
        $node2 = $node1->ownerDocument->importNode($dom_sxe, true);
        $node1->parentNode->replaceChild($node2, $node1);

        return $this;
    }
55231
protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;

        switch ($absoluteNodeName) {
            case $this->lookupNamespace('gphoto') . ':' . 'weight';
                $weight = new Zend_Gdata_Photos_Extension_Weight();
                $weight->transferFromDOM($child);
                $this->_gphotoWeight = $weight;
                break;
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
223072
protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;

        switch ($absoluteNodeName) {

            case $this->lookupNamespace('apps') . ':' . 'property';
                $property = new Zend_Gdata_Gapps_Extension_Property();
                $property->transferFromDOM($child);
                $this->_property[] = $property;
                break;
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
38898
public function addChild(Acl $child)
    {
        $rules = $child->getRule();
        foreach ($rules as $rule) {
            $this->rules[] = $rule;
        }
        return $this;
    }
891167
protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        switch ($absoluteNodeName) {
        case $this->lookupNamespace('exif') . ':' . 'tags':
            $tags = new Zend_Gdata_Exif_Extension_Tags();
            $tags->transferFromDOM($child);
            $this->_tags = $tags;
            break;
        default:
            parent::takeChildFromDOM($child);
            break;
        }
    }
170916
protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        switch ($absoluteNodeName) {
        case $this->lookupNamespace('yt') . ':' . 'position':
            $position = new Zend_Gdata_YouTube_Extension_Position();
            $position->transferFromDOM($child);
            $this->_position = $position;
            break;
        default:
            parent::takeChildFromDOM($child);
            break;
        }
    }
1146036
protected function replaceChild(Node $child, Node $replacement) {
    foreach ($this->getChildProperties() as $name => $value) {
      if ($child === $value) {
        $this->{$name} = $replacement;
        break;
      }
    }
    $replacement->parent = $this;
    $replacement->previous = $child->previous;
    $replacement->next = $child->next;
    if ($child->previous === NULL) {
      $this->head = $replacement;
    }
    else {
      $child->previous->next = $replacement;
    }
    if ($child->next === NULL) {
      $this->tail = $replacement;
    }
    else {
      $child->next->previous = $replacement;
    }
    $child->parent = NULL;
    $child->previous = NULL;
    $child->next = NULL;
    return $this;
  }
611112
public function addChild(LayoutInterface $child)
    {
        $this->children->add($child);
        $child->setParent($this);

        return $this;
    }
393513
protected function replaceChild($string)
    {
        if (!empty($string)) {
            $newDocument = new Document($string);

            if ($newDocument->outertext !== $string) {
                throw new RuntimeException('Not valid HTML fragment');
            }
        }

        foreach ($this->node->childNodes as $node) {
            $this->node->removeChild($node);
        }

        if (!empty($string)) {
            $newNode = $this->node->ownerDocument->importNode($newDocument->getDocument()->documentElement, true);
            $this->node->appendChild($newNode);
        }

        return $this;
    }
1202527
public function insert($index, $child, $replace = FALSE)
	{
		if ($child instanceof self || is_scalar($child)) {
			if ($index === NULL) { // append
				$this->children[] = $child;

			} else { // insert or replace
				array_splice($this->children, (int)$index, $replace ? 1 : 0, [$child]);
			}

		} else {
			throw new InvalidArgumentException(sprintf('Child node must be scalar or Html object, %s given.', is_object($child) ? get_class($child) : gettype($child)));
		}

		return $this;
	}
318703
protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;

        switch ($absoluteNodeName) {
            case $this->lookupNamespace('gml') . ':' . 'Point';
                $point = new Zend_Gdata_Geo_Extension_GmlPoint();
                $point->transferFromDOM($child);
                $this->_point = $point;
                break;
        }
    }
433090
public function addChild(NodeContract $child)
    {
        $this->children[] = $child;

        $child->setParent($this);
        $child->setIndex(count($this->children) - 1);

        return $this;
    }
261117
protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        switch ($absoluteNodeName) {
        case $this->lookupNamespace('openSearch') . ':' . 'totalResults':
            $totalResults = new Zend_Gdata_Extension_OpenSearchTotalResults();
            $totalResults->transferFromDOM($child);
            $this->_totalResults = $totalResults;
            break;
        case $this->lookupNamespace('openSearch') . ':' . 'startIndex':
            $startIndex = new Zend_Gdata_Extension_OpenSearchStartIndex();
            $startIndex->transferFromDOM($child);
            $this->_startIndex = $startIndex;
            break;
        case $this->lookupNamespace('openSearch') . ':' . 'itemsPerPage':
            $itemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage();
            $itemsPerPage->transferFromDOM($child);
            $this->_itemsPerPage = $itemsPerPage;
            break;
        default:
            parent::takeChildFromDOM($child);
            break;
        }
    }
371046
public function appendChild( $child = null /* .. AbstractElement $element .. */ ) {
		$arg_list = func_get_args();

		foreach( $arg_list as $arg ) {
			if( $arg instanceof AbstractElement ) {
				$inject = $arg;
			} elseif( is_scalar($arg) ) {
				$inject = new Text($arg);
			} else {
				throw new \InvalidArgumentException;
			}

			$inject->_setParent($this);
			$this->childElements[] = $inject;
		}

		return $this;
	}
564108
function addChildX(X $child) {
		/** @var X $childInThis */
		$childInThis = $this->addChild($child->getName(), (string)$child);
		foreach ($child->attributes() as $attr => $value) {
			/** @var string $name */
			/** @var string $value */
			$childInThis->addAttribute($attr, $value);
		}
		foreach ($child->children() as $childChild) {
			/** @var X $childChild */
			$childInThis->addChildX($childChild);
		}
	}
783744
public function appendChild(Element $element)
	{
		$this->beforeInsert($element);
		
		array_push($this->children, $element);
		
		$this->afterInsert();
		
		return $this;
	}
229257
public function replaceChild(SimpleXMLElement $new, SimpleXMLElement $old)
    {
        $tmp = dom_import_simplexml($this);
        $new = $tmp->ownerDocument->importNode(dom_import_simplexml($new), true);

        $node = $tmp->replaceChild($new, dom_import_simplexml($old));

        return simplexml_import_dom($node, get_class($this));
    }