lykoulos
09-07-2009, 06:23 AM
Hello, I have a PHP file which writes items on an rss.xml file.
The XML file ends in </channel></rss>
This is the last line.
The thing is, that every time the PHP writes a new item on the XML file, it must delete the last line of the XML file first. How can I do this? This is my code, please help.
<?php
header ("Location: http://www.google.com");
$handlexml = fopen("rss.xml", "a");
$time = date("h:i:s",time() + 7200);
$imerom = date("j-m-Y");
$data = "rss.xml";
fwrite($handlexml, "<item>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<title>");
fwrite($handlexml, "$imerom");
fwrite($handlexml, " ");
fwrite($handlexml, "$date");
fwrite($handlexml, "</title>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<link>http://www.google.com");
fwrite($handlexml, "</link>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<guid>http://www.google.com");
fwrite($handlexml, "</guid>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<pubDate>Mon, 10 Sep 2009 18:37:00 GMT</pubDate>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<description>decriptio</description>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "</item>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "</channel></rss>");
fclose($handlexml);
exit;
?>
The XML file ends in </channel></rss>
This is the last line.
The thing is, that every time the PHP writes a new item on the XML file, it must delete the last line of the XML file first. How can I do this? This is my code, please help.
<?php
header ("Location: http://www.google.com");
$handlexml = fopen("rss.xml", "a");
$time = date("h:i:s",time() + 7200);
$imerom = date("j-m-Y");
$data = "rss.xml";
fwrite($handlexml, "<item>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<title>");
fwrite($handlexml, "$imerom");
fwrite($handlexml, " ");
fwrite($handlexml, "$date");
fwrite($handlexml, "</title>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<link>http://www.google.com");
fwrite($handlexml, "</link>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<guid>http://www.google.com");
fwrite($handlexml, "</guid>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<pubDate>Mon, 10 Sep 2009 18:37:00 GMT</pubDate>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "<description>decriptio</description>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "</item>");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "\r\n");
fwrite($handlexml, "</channel></rss>");
fclose($handlexml);
exit;
?>