DomNode::clone_node

(PHP 4 >= 4.1.0)

DomNode::clone_node Clones a node

Описание

domelement DomNode::clone_node ( void )

Внимание

К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.

[an error occurred while processing the directive]

Коментарии

Passing boolean 'true' as the argument to this function will result in all child nodes being cloned as well.
2005-05-11 11:28:45
http://php5.kiev.ua/manual/ru/function.domnode-clone-node.html
As of version 4.3 PHP doesn't support Appending a child from another source document. If you are trying to  import information from multiple sources into a final document [for transformation using XSL as an example] then you can have problems. This technique can be used to do it though.

I am assuming you have two documents open, $xmldoc1 and $xmldoc2 and you have selected [via XPath or explicit searching] the nodes you want in each document. Thus $xmldoc1_appending_node is the node you would like to add $xmldoc2_importnode to.

<?

// first we create a temporary node within the document we want to add to.
$temp_importnode $xmldoc1->create_element("import");

// now we have a node that is in the right document context we can clone the one we want into this one.
$temp_importnode $xmldoc_importnode->clone_node(true);

// by using true in the above call to clone_node() we copy all of the child nodes as well. Use false or nothing if you just want the containing node with no children.

$xmldoc1_appending->append_child($importnode);

?>

Now your document contains the new nodes imported from a different document.
2006-02-12 09:04:23
http://php5.kiev.ua/manual/ru/function.domnode-clone-node.html
It seems like this function is non-recursive: cloning a node will not clone it's child nodes in my experience
2006-06-05 17:41:06
http://php5.kiev.ua/manual/ru/function.domnode-clone-node.html

    Поддержать сайт на родительском проекте КГБ