src/SimpleDOM.php
public function removeNodes($xpath)
    {
        if (!is_string($xpath)) {
            throw new InvalidArgumentException(
                'Argument 1 passed to removeNodes() must be a string, ' . gettype($xpath) . ' given'
            );
        }

        $nodes = $this->_xpath($xpath);

        if (isset($nodes[0])) {
            $tmp = dom_import_simplexml($nodes[0]);

            if ($tmp->isSameNode($tmp->ownerDocument->documentElement)) {
                unset($nodes[0]);
            }
        }

        $return = array();
        foreach ($nodes as $node) {
            $return[] = $node->removeSelf();
        }

        return $return;
    }
public function removeNodes($xpath)
    {
        if (!is_string($xpath)) {
            throw new InvalidArgumentException(
                'Argument 1 passed to removeNodes() must be a string, ' . gettype($xpath) . ' given'
            );
        }

        $nodes = $this->_xpath($xpath);

        if (isset($nodes[0])) {
            $tmp = dom_import_simplexml($nodes[0]);

            if ($tmp->isSameNode($tmp->ownerDocument->documentElement)) {
                unset($nodes[0]);
            }
        }

        $return = array();
        foreach ($nodes as $node) {
            $return[] = $node->removeSelf();
        }

        return $return;
    }
Remove all elements matching a XPath expression

@param    string $xpath XPath expression
@throws InvalidArgumentException
@return    array            Array of removed nodes on success or FALSE on failure