lykoulos Posted September 7, 2009 Share Posted September 7, 2009 Hello, I have a PHP file which writes items on an rss.xml file. The XML file ends in </rss> 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, "</rss>"); fclose($handlexml); exit; ?> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted September 7, 2009 Share Posted September 7, 2009 have a look at the native functionality for doing such things http://uk2.php.net/manual/en/refs.xml.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.