1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| //1er xml
private $containedDocXml;
private $containedXPath;
//2e xml
private $containerDocXml;
private $containerXPath;
private $identifier;
//je cherche le noeud a exporter dans le 1er xml
$exportedNode = $this->containedXPath->query("//imscp:manifest/imscp:organizations/imscp:organization");
//j'importe le noeud du 1er xml dans le 2e xml
$importedNode = $this->containerDocXml->importNode($exportedNode->item(0),true);
//je cherche l'endroit ou le coller dans le 2e xml
$insertBeforeThisNode = $this->containerXPath->query("//imscp:manifest/imscp:organizations/imscp:organization/imscp:item[@identifier='$identifier']");
//la racine du 2e xml
$racine = $this->containerDocXml->documentElement;
//je l'insere avant ce noeud dans xml2
$racine->insertBefore($importedNode,$insertBeforeThisNode->item(0)); |
Partager