note 26818 added to function.domdocument-create-element
| From: | greg at cabinetuk dot php dot net | Date: | Wed, 13 Nov 2002 23:27:03 +0000 |
| Subject: | note 26818 added to function.domdocument-create-element | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39462@lists.php.net to get a copy of this message | ||
Its important to remember, when adding a created element to an existing node using append_child(),
that if you want to then add another element to that node you have to go back and set up a DOMNode
instance using DOMDocument_get_elements_by_tagname or similar before you can append another node
onto it.
eg
<?
$new_element = $dom->create_element("new_element");
$oldTag->append_child($new_element);
//Go back and set up new element as DOMNode
$new_elementArray = $dom->get_elements_by_tagname("new_element");
$new_elementTag = $new_elementArray[0];//(if theres more than one use a for loop)
$new_elementTag->append_child("another_new_element");
?>
--
http://www.php.net/manual/en/function.domdocument-create-element.php
http://master.php.net/manage/user-notes.php?action=edit+26818
http://master.php.net/manage/user-notes.php?action=delete+26818
http://master.php.net/manage/user-notes.php?action=reject+26818