note 69132 deleted from ref.dom by didou

From: Date: Sat, 30 Dec 2006 03:01:53 +0000
Subject: note 69132 deleted from ref.dom by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121036@lists.php.net to get a copy of this message
Note Submitter: ashwinee_raut at yahoo dot com ---- I found a lot about how to add new elements to existing xml file using PHP 5.0.4. Here is the code- $file_name="my_xml.xml"; $dom = new DomDocument(); $dom->load($file_name); $item = $dom->createElement("item"); $title = $dom->createElement("title"); $link=$dom->createElement("link"); $titletext = $dom->createTextNode("New Title"); $title->appendChild($titletext); $link_text=$dom->createTextNode("New Link"); $link->appendChild($link_text); $item->appendChild($title); $item->appendChild($link); $dom->documentElement->appendChild($item); $dom->save($file_name); This will load xml file.. append new element to it and then save it back to the file..

« previous php.notes (#121036) next »