--TEST-- Cloning a whole document --EXTENSIONS-- dom --FILE-- ]> afoob &foo; XML); echo "---\n"; var_dump($dom->getElementsByTagName("child2")[0]->firstChild->nodeName); echo "---\n"; $clone = clone $dom; echo $clone->saveXml(), "\n"; var_dump($clone->getElementsByTagName("child2")[0]->firstChild->nodeName); echo "---\n"; $clone = $dom->cloneNode(false); echo $clone->saveXml(), "\n"; echo "---\n"; $clone = $dom->documentElement->cloneNode(false); echo $clone->ownerDocument->saveXml($clone), "\n"; ?> --EXPECT-- --- string(3) "foo" --- ]> afoob &foo; string(3) "foo" --- ---