public function replace(DOMElement &$old, &$new)
    {
        // Check if the element has a parent node
        if (empty($old->parentNode)) {
            throw new DOMException('The current DOMItem has no parent.');
        }

        // Replace the element
        $old->parentNode->replaceChild($new, $old);

        return $new;
    }
public function replace(DOMElement &$old, &$new)
    {
        // Check if the element has a parent node
        if (empty($old->parentNode)) {
            throw new DOMException('The current DOMItem has no parent.');
        }

        // Replace the element
        $old->parentNode->replaceChild($new, $old);

        return $new;
    }
public function replace ( DOMElement & $ old , & $ new ) { // Check if the element has a parent node if ( empty ( $ old -> parentNode ) ) { throw new DOMException ( 'The current DOMItem has no parent.' ) ; } // Replace the element $ old -> parentNode -> replaceChild ( $ new , $ old ) ; return $ new ; }
Replace the DOMItem.

@param DOMElement $old The DOMElement to handle.
@param DOMNode    $new The item to replace.

@return DOMElement|DOMNode The new element.

@throws Exception
Replace the DOMItem .