1
je veux fusionner un PHP DOMDocument dans un autre ..xml Merge en PHP DOM
//this creates the DOM which will be imported
function element_index(..)
{
$skrit=new DOMDocument();
$skrit->loadXML('<krits:kriti xmlns:krits="http://test.de/krits">..</krits:kriti>');
return $skrit;
}
function crawl_xml($element)
{
//thats the line where to get the result and merge
$skrit=element_index(..);
$temp3=$skrit->documentElement->cloneNode(true);
$element->appendChild($xpIn->importNode($temp3));
}
//thats how i start the recurisve walking through Nodes
$xpIn = new DOMDocument();
crawl_xml($xpIn->firstChild);
L'entrée/sortie doit comme ceci:
<!--input-->
<all><one/></all>
<!--input new to add-->
<krits:kriti xmlns:krits="http://test.de/krits">..</krits:kriti>
<!--ouput-->
<all><krits:kriti xmlns:krits="http://test.de/krits">..</krits:kriti><one><krits:kriti xmlns:krits="http://test.de/krits">..</krits:kriti></one></all>
peut-être importNode peut-être pas un bon choix? Le cloneNode que j'ai utilisé parce que j'espérais éviter les problèmes avec l'appel récursif .. Alors qu'est-ce que je fais mal? Merci de votre aide!