public function merge(SimpleXmlElement $element, $replace = true, $rule = null)
    {
        foreach ($element->children() as $name => $child) {
            $affected = null;
            $currentpath = $child->getPath();
            $action = $this->_getMergeRule($child, $affected, $rule);

            if ($action == self::MERGE_APPEND) {
                $affected = $this->addChild($name, (string)$child);
            }

            if (!$affected instanceof SimpleXmlElement) {
                continue;
            }

            $affected->mergeAttributes($child, $replace);

            if ($child->hasChildren()) {
                $affected->merge($child, $replace, $rule);
                continue;
            } else if ($replace) {
                $affected[0] = (string)$child;
            }
        }

        return $this;
    }
public function merge(SimpleXmlElement $element, $replace = true, $rule = null)
    {
        foreach ($element->children() as $name => $child) {
            $affected = null;
            $currentpath = $child->getPath();
            $action = $this->_getMergeRule($child, $affected, $rule);

            if ($action == self::MERGE_APPEND) {
                $affected = $this->addChild($name, (string)$child);
            }

            if (!$affected instanceof SimpleXmlElement) {
                continue;
            }

            $affected->mergeAttributes($child, $replace);

            if ($child->hasChildren()) {
                $affected->merge($child, $replace, $rule);
                continue;
            } else if ($replace) {
                $affected[0] = (string)$child;
            }
        }

        return $this;
    }
public function merge ( SimpleXmlElement $ element , $ replace = true , $ rule = null ) { foreach ( $ element -> children ( ) as $ name => $ child ) { $ affected = null ; $ currentpath = $ child -> getPath ( ) ; $ action = $ this -> _getMergeRule ( $ child , $ affected , $ rule ) ; if ( $ action == self :: MERGE_APPEND ) { $ affected = $ this -> addChild ( $ name , ( string ) $ child ) ; } if ( ! $ affected instanceof SimpleXmlElement ) { continue ; } $ affected -> mergeAttributes ( $ child , $ replace ) ; if ( $ child -> hasChildren ( ) ) { $ affected -> merge ( $ child , $ replace , $ rule ) ; continue ; } else if ( $ replace ) { $ affected [ 0 ] = ( string ) $ child ; } } return $ this ; }
merge another xml element into this one

@param SimpleXmlElement $element
@return string
merge another xml element into this one