Merge xml in PHP DOM -


i want merge php domdocument in another..

//this creates dom 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 line result , merge       $skrit=element_index(..); $temp3=$skrit->documentelement->clonenode(true); $element->appendchild($xpin->importnode($temp3)); }  //thats how start recurisve walking through nodes $xpin = new domdocument(); crawl_xml($xpin->firstchild); 

the input/output should this:

<!--input--> <all><one/></all>  <!--input new 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> 

maybe importnode might not choice? clonenode used because hoped avoid problems recursive call.. doing wrong? help!

if want import whole node sub-tree (and not node itself), need set $deep true in importnode:

$domdocument->importnode($node, true); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -