note 44296 deleted from function.dom-domnode-replacechild by didou

From: Date: Sun, 29 Aug 2004 21:38:10 +0000
Subject: note 44296 deleted from function.dom-domnode-replacechild by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75590@lists.php.net to get a copy of this message
Note Submitter: zjcboy at hotpop dot com ---- The order of the parameters is wrong, should be replaceChild($newChild, $oldChild) replaceChild($oldChild, $newChild) will not work and report "Not Found Error" example: <?PHP $xml = <<<EOD <root><child><role>son</role></child></root> EOD; $doc = new DomDocument; $doc->loadXML($xml); $root = $doc->firstChild; $oldChild = $root->firstChild; $newDoc = new DomDocument; $newChild = $newDoc->createElement('child'); $newRole = $newDoc->createElement('role', 'daughter'); $newChild->appendChild($newRole); $newChild = $doc->importNode($newChild, TRUE); $root->replaceChild($newChild, $oldChild); echo $doc->saveXML(); ?>

« previous php.notes (#75590) next »