note 42056 added to function.domnode-append-sibling
| From: | s dot girard at pandora dot be | Date: | Sat, 01 May 2004 03:06:44 +0000 |
| Subject: | note 42056 added to function.domnode-append-sibling | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69059@lists.php.net to get a copy of this message | ||
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");
----
Manual Page -- http://www.php.net/manual/en/function.domnode-append-sibling.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42056
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42056&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42056&report=yes
Search -- http://master.php.net/manage/user-notes.php