As of PHP 5.1.6 with libxml 2.6.26 and DOM/XML API version 20031129, importNode() does nothing if attempting to import from the same document. Meaning, if you do an $ret = importNode and then appendChild($ret) or insertBefore($ret, ...) then you will end up *moving* the node instead of ending up with a copy.If you expect importNode to give you a copy of the source (in this case, a deep copy) then you must account for them being from the same document. This function addresses this:<?// Import $b into $a's documentfunction myimport($a, $b){ if ($a->ownerDocument->isSameNode($b->ownerDocument)) { $temp = new DOMDocument(); $ret = $temp->importNode($b, TRUE); return $a->ownerDocument->importNode($ret, TRUE); } else { return $a->ownerDocument->importNode($b, TRUE); }}?>(Function was freshly coded for this note but I based it off another, working function of mine.)This function checks if the documents are the same and uses a new document (guaranteed to be different this way) to force a copy into $temp and then force a copy back into $a->ownerDocument.Obviously, no error checking has been done.