PHP: DomNode->append_sibling - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DomNode->attributes DomNode->append_child

Last updated: Fri, 26 Jan 2007

view this page in

# DomNode->append_sibling

(no version information, might be only in CVS)

DomNode->append_sibling -- Adds new sibling to a node

## Описание

domelement DomNode->append_sibling ( domelement newnode )

This functions appends a sibling to an existing node. The child can be created with e.g. domdocument_create_element(), domdocument_create_text() etc. or simply by using any other node.

Before a new sibling is added 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 added sibling. If you plan to do further modifications on the added sibling you must use the returned node.

This function has been added to provide the behaviour of domnode_append_child() as it works till PHP 4.2.

See also domnode_append_before().

add a note User Contributed Notes
DomNode->append_sibling
s dot girard at pandora dot be
30-Apr-2004 11:06
`Small example on the use of domnode->append_sibling()
This function creates a news.xml file, that will be later on parsed with XSLT.
$doc = domxml_new_doc("1.0");
$root = $doc->create_element("rt");
$root = $doc->append_child($root);
$page = $doc->create_element("page");
$page = $root->append_child($page);
$page->set_attribute("pageimage","images/news.jpg");
while($row = mysql_fetch_row($result))
{
$news = $doc->create_element("news");
$news = $page->append_child($news);
$topic = $doc->create_element("topic");
$topic = $news->append_child($topic);
$topic_content = $doc->create_text_node($row[0]);
$topic_content = $topic->append_child($topic_content);
$user = $doc->create_element("user");
$user = $topic->append_sibling($user);
$user_content = $doc->create_text_node($row[3]);
$user_content = $user->append_child($user_content);
$date = $doc->create_element("date");
$date = $topic->append_sibling($date);
$date_content = $doc->create_text_node($row[2]);
$date_content = $date->append_child($date_content);
$body = $doc->create_element("body");
$body = $topic->append_sibling($body);
$body_content = $doc->create_text_node($row[1]);
$body_content = $body->append_child($body_content);
}
unlink("./data/news.xml");
$doc->dump_file("./data/news.xml");`
add a note
DomNode->attributes DomNode->append_child

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST