note 76322 modified in function.simplexml-element-addChild by danbrown

From: Date: Wed, 16 Sep 2009 16:38:49 +0000
Subject: note 76322 modified in function.simplexml-element-addChild by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160743@lists.php.net to get a copy of this message
Replacing a node is an easy mod of the simplexml_append <?php function simplexml_replace(SimpleXMLElement $parent, SimpleXMLElement $new_child){ $node1 = dom_import_simplexml($parent); $dom_sxe = dom_import_simplexml($new_child); $node2 = $node1->ownerDocument->importNode($dom_sxe, true); $node1->parentNode->replaceChild($node2,$node1); } ?> --was-- Replacing a node is an easy mod of the simplexml_append <?php function simplexml_replace(SimpleXMLElement $parent, SimpleXMLElement $new_child){ $node1 = dom_import_simplexml($parent); $dom_sxe = dom_import_simplexml($new_child); $node2 = $node1->ownerDocument->importNode($dom_sxe, true); $node1->parentNode->replaceChild($node2,$node1); } ?> http://php.net/manual/en/function.simplexml-element-addChild.php

« previous php.notes (#160743) next »