DOMDocument::adoptNode
Transfer a node from another document
&reftitle.description;
public DOMNodefalseDOMDocument::adoptNode
DOMNodenode
Transfer a node from another document into the current document.
&reftitle.parameters;
node
The node to transfer.
&reftitle.returnvalues;
The node that was transfered, or &false; on error.
&reftitle.errors;
DOM_NOT_SUPPORTED_ERR
Raised if the node type is not supported for document transfers.
&reftitle.examples;
DOMDocument::adoptNode example
Transfers the hello element from the first document to the second one.
loadXML("");
$hello = $doc1->documentElement->firstChild;
$doc2 = new DOMDocument;
$doc2->loadXML("");
$doc2->documentElement->appendChild($doc2->adoptNode($hello));
echo $doc1->saveXML() . PHP_EOL;
echo $doc2->saveXML();
?>
]]>
&example.outputs;
]]>
&reftitle.seealso;
DOMDocument::importNode