|
(no version information, might be only in CVS)
DomNode->append_child -- Adds new child at the end of the childrenThis functions appends a child to an existing list of children or creates a new list of children. The child can be created with e.g. domdocument_create_element(), domdocument_create_text() etc. or simply by using any other node.
(PHP < 4.3) Before a new child is appended it is first duplicated. Therefore the new child is a completely new copy which can be modified without changing the node which was passed to this function. If the node passed has children itself, they will be duplicated as well, which makes it quite easy to duplicate large parts of an XML document. The return value is the appended child. If you plan to do further modifications on the appended child you must use the returned node.
(PHP 4.3.0/4.3.1) The new child newnode is first unlinked from its existing context, if it's already a child of DomNode. Therefore the node is moved and not copies anymore.
(PHP >= 4.3.2) The new child newnode is first unlinked from its existing context, if it's already in the tree. Therefore the node is moved and not copied. This is the behaviour according to the W3C specifications. If you want to duplicate large parts of an XML document, use DomNode->clone_node() before appending.
The following example will add a new element node to a fresh document and sets the attribute "align" to "left".
See also domnode_insert_before(), and domnode_clone_node().
Poprzedni | Spis treści | Następny |
DomNode->add_namespace | Początek rozdziału | DomNode->append_sibling |
Hosting by: Hurra Communications Sp. z o.o.
Generated: 2007-01-26 18:02:25