note 101106 modified in domdocument.createelement by danbrown

From: Date: Fri, 26 Nov 2010 15:31:37 +0000
Subject: note 101106 modified in domdocument.createelement by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174386@lists.php.net to get a copy of this message
You may think insertBefore and insertAfter is a direct alternative for appendChild, this is not the case. <?php $dom = new DOMDocument(); $dom->load($file); $dom->appendChild($newNode); //Works fine $dom->insertBefore($newNode, $refNode); //Will fail $refNode->parentNode->insertBefore($newNode, $refNode); // thanx to yasindagli (first post) ?> --was-- You may think insertBefore and insertAfter is a direct alternative for appendChild, this is not the case. $dom = new DOMDocument(); $dom->load($file); $dom->appendChild($newNode); //Works fine $dom->insertBefore($newNode, $refNode); //Will fail $refNode->parentNode->insertBefore($newNode, $refNode); // thanx to yasindagli (first post) http://php.net/manual/en/domdocument.createelement.php

« previous php.notes (#174386) next »