note 42056 deleted from function.domnode-append-sibling by sobak

From: Date: Tue, 22 Nov 2016 03:34:57 +0000
Subject: note 42056 deleted from function.domnode-append-sibling by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207370@lists.php.net to get a copy of this message
Note Submitter: s dot girard at pandora dot be ---- 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");

« previous php.notes (#207370) next »