note 116939 added to domdocument.createelement

From: Date: Tue, 24 Mar 2015 17:42:54 +0000
Subject: note 116939 added to domdocument.createelement
Groups: php.notes 
Request: Send a blank email to php-notes+get-202025@lists.php.net to get a copy of this message
Remember: If you want to perform multiple actions with a new node, you may need to create a copy of it before means: ## Create an address to an unique memory block ! $td = $dom->createElement('td'); ## Change some things in this original unique pattern $td->setAttribute('class', 'saldo'); ## clone the unique pattern to two own one's $td1 = clone $td; $td2 = clone $td; ## alter properties in each one $td1->nodeValue = 'Ich bin die erste neue Node'; $td2->nodeValue = 'Ich bin die zweite neue Node'; ## find the parent element $tr = $dom->getElementById('t001-tr001'); ## find the first and the last child (here only for clearity) $first = $tr->firstChild; $last = $tr->lastChild; ## produce the new nodes $newtd1 = $tr->insertBefore($td1, $first); $newtd2 = $tr->appendChild($td2); conclusion: YOU NEED AN ORIGINAL NEW NODE FOR EACH ACTION! ---- Server IP: 72.52.91.14 Probable Submitter: 80.140.127.253 ---- Manual Page -- http://php.net/manual/en/domdocument.createelement.php Edit -- https://master.php.net/note/edit/116939 Del: integrated -- https://master.php.net/note/delete/116939/integrated Del: useless -- https://master.php.net/note/delete/116939/useless Del: bad code -- https://master.php.net/note/delete/116939/bad+code Del: spam -- https://master.php.net/note/delete/116939/spam Del: non-english -- https://master.php.net/note/delete/116939/non-english Del: in docs -- https://master.php.net/note/delete/116939/in+docs Del: other reasons-- https://master.php.net/note/delete/116939 Reject -- https://master.php.net/note/reject/116939 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202025) next »