I want to create a data.xml file as a log of my all incoming contact. Does anyone can simply give me some hint and help me to edit the following code. What I need to do it to remove the beginning <log> and end </log> everytime before I append the new data. Thanks in advance.
$oldinfo = file_get_contents("data.xml");
$guestbookdata = fopen("data.xml", "w+");
fwrite($guestbookdata, "<log>");
fwrite($guestbookdata, "<mailer><name>$fromname</name>");
fwrite($guestbookdata, "<JSTdatetime>$timedate</JSTdatetime>");
fwrite($guestbookdata, "<subject>$subject</subject>");
fwrite($guestbookdata, "<msg>$body</msg>");
fwrite($guestbookdata, "<sendip>$senderip</sendip></mailer>");
fwrite($guestbookdata, "$oldinfo");
fwrite($guestbookdata, "</log>");
fclose($guestbookdata);