appending to stored form input in xml file.... ????
| From: | toby z | Date: | Tue, 18 Jun 2002 06:51:53 +0000 |
| Subject: | appending to stored form input in xml file.... ???? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-14257@lists.php.net to get a copy of this message | ||
im trying to store input from my form into ctnt.xml
file thru
ctnt.php
the problem is ....
how do i append to this file ie
i want the input of each form subbmission to get
stored in this same ctnt.xml
without overwriting ....
i now i sholud use $fp=fopen("c:\\name.xml", "a+");
i get an error ven i try to open n.xml in internet
explorer
& here is the error i get :
"XML document must have a top level element. Error
processing resource file:///C:/n.xml'. "
here is my ctnt.php file ....
<?php
$doc = domxml_new_doc("1.0");
$fp=fopen("c:\\n.xml", "a+");
$ctnt_root = $doc->create_element("ctnt-root");
$ctnt_root = $doc->append_child($ctnt_root);
$fp=fopen("c:\\n.xml", "a+");
$ctnt_info= $doc->create_element("ctnt-info");
$ctnt_info = $ctnt_root->append_child($ctnt_info);
$sr_no = $doc->create_element("sr-no");
$sr_no = $ctnt_info->append_child($sr_no);
$txt = $doc->create_text_node("$srno");
$txt = $sr_no->append_child($txt);
$cat_id = $doc->create_element("cat-id");
$cat_id = $ctnt_info->append_child($cat_id);
$txt = $doc->create_text_node("$cat");
$txt = $cat_id->append_child($txt);
$lang_id = $doc->create_element("lang-id");
$lang_id = $ctnt_info->append_child($lang_id);
$txt = $doc->create_text_node("$lang");
$txt = $lang_id->append_child($txt);
$memb_id = $doc->create_element("memb-id");
$memb_id = $ctnt_info->append_child($memb_id);
$txt = $doc->create_text_node("$login");
$txt = $memb_id->append_child($txt);
$ttle = $doc->create_element("title");
$ttle = $ctnt_info->append_child($ttle);
$txt = $doc->create_text_node("$title");
$txt = $ttle->append_child($txt);
$bdy = $doc->create_element("body");
$bdy = $ctnt_info->append_child($bdy);
$txt = $doc->create_text_node("$body");
$txt = $bdy->append_child($txt);
$date_time = $doc->create_element("date-time");
$date_time = $ctnt_info->append_child($date_time);
$txt = $doc->create_text_node("$date_time");
$txt = $date_time->append_child($txt);
$doc->dump_file("c:\\ctnt.xml", false, true);
//$fp=fopen("c:\\ctnt.xml", "wb");
//fwrite($fp, "$root");
?>
m i messing it up somewhere ????
id really appriciate any help ....
& please do letme know if i sholud send the form as
well ....
thnx a million .....
mr. seven-rude-son (b.a.t hkg).... ive tried to
improve on my WRITTING ! ! ! !
toby ....
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com