src/SimpleDOM.php
public function insertXML($xml, $mode = 'append')
    {
        $tmp = dom_import_simplexml($this);
        $fragment = $tmp->ownerDocument->createDocumentFragment();

        /**
         * Disable error reporting
         */
        $use_errors = libxml_use_internal_errors(true);

        if (!$fragment->appendXML($xml)) {
            libxml_use_internal_errors($use_errors);
            throw new InvalidArgumentException(libxml_get_last_error()->message);
        }
        libxml_use_internal_errors($use_errors);

        $this->insertNode($tmp, $fragment, $mode);

        return $this;
    }
public function insertXML($xml, $mode = 'append')
    {
        $tmp = dom_import_simplexml($this);
        $fragment = $tmp->ownerDocument->createDocumentFragment();

        /**
         * Disable error reporting
         */
        $use_errors = libxml_use_internal_errors(true);

        if (!$fragment->appendXML($xml)) {
            libxml_use_internal_errors($use_errors);
            throw new InvalidArgumentException(libxml_get_last_error()->message);
        }
        libxml_use_internal_errors($use_errors);

        $this->insertNode($tmp, $fragment, $mode);

        return $this;
    }
Insert raw XML data

@param    string $xml XML to insert
@param    string $mode Where to add this tag: 'append' to current node,
'before' current node or 'after' current node
@throws BadMethodCallException
@throws InvalidArgumentException
@return    SimpleDOM            Current node