gardan06 Posted August 28, 2006 Share Posted August 28, 2006 i'm asked to do a program where user could make their own articles and convert it into an RSS Feed. the problem ive had is that when i use fopen("test.xml","w") and an XML file is created, its contents does contain the script you usually see in an RSS XML Feed but it doesnt output like an RSS Feed, but rather generates this error: "Parse error: parse error, unexpected T_STRING in C:\Program Files\xampp\htdocs\aaaa.xml on line 1"this is my script:[quote]<? $link1 = "http://radio.weblogs.com/0001011/"; $link2 = "http://radio.weblogs.com/0001011/2005/11/27.html#a11433"; $link3 = "http://scobleizer.wordpress.com/"; $link4 = "http://scobleizer.wordpress.com/feed/"; $link5 = "http://radio.weblogs.com/0001011/2005/11/27.html#a11433"; $link6 = "http://scoblecomments2.scripting.com/comments?u=1011&p=11433&link=http%3A%2F%2Fradio.weblogs.com%2F0001011%2F2005%2F11%2F27.html%23a11433"; $text = "<?xml version=\"1.0\" ?>\r\n"; $text .= "<rss version=\"2.0\">\r\n"; $text .= "<channel>\r\n"; $text .= "<title>Scobleizer: Microsoft Geek Blogger</title>\r\n"; $text .= "<link>".$link1."</link>\r\n"; $text .= "<description>Robert Scoble\'s look at geek and Microsoft life.</description>\r\n"; $text .= "<language>en-us</language>\r\n"; $text .= "<copyright>Copyright 2005 Robert Scoble</copyright>\r\n"; $text .= "<item>\r\n"; $text .= "<title>PLEASE SUBSCRIBE TO MY NEW BLOG</title>\r\n"; $text .= "<link>".$link2."</link>\r\n"; $text .= "<description><p>Hello, we know you\'re still subscribed to this blog (9,000 of you are on Bloglines, for instance). So, please unsubscribe from this blog and come over and visit me in my new home at <a href=\"".$link3."\">".$link3."</a></p> <p>My new RSS feed is here: <a href=\"".$link4."\">".$link4."</a></p> <p>I have permanently moved over there, so please do come and visit!</p></description>\r\n"; $text .= "<guid>".$link5."</guid>\r\n"; $text .= "<pubDate>Sun, 27 Nov 2005 13:44:16 GMT</pubDate>\r\n"; $text .= "<comments>".$link6."</comments>\r\n"; $text .= "</item>\r\n"; $text .= "</channel>\r\n"; $text .= "</rss>"; if ($fp = fopen("aaaa.xml","w")) { fwrite($fp,$text); fclose($fp); echo "XML has been written. <a href=\"aaaa.xml\">View the XML.</a>"; } else { echo "could not save"; }?>[/quote]what'ts wrong with my script? Link to comment https://forums.phpfreaks.com/topic/18947-creating-an-rss-xml-file-using-php/ Share on other sites More sharing options...
gardan06 Posted August 28, 2006 Author Share Posted August 28, 2006 pls help.. Link to comment https://forums.phpfreaks.com/topic/18947-creating-an-rss-xml-file-using-php/#findComment-81835 Share on other sites More sharing options...
hitman6003 Posted August 28, 2006 Share Posted August 28, 2006 See if this works for you:[code]<?php$link1 = "http://radio.weblogs.com/0001011/";$link2 = "http://radio.weblogs.com/0001011/2005/11/27.html#a11433";$link3 = "http://scobleizer.wordpress.com/";$link4 = "http://scobleizer.wordpress.com/feed/";$link5 = "http://radio.weblogs.com/0001011/2005/11/27.html#a11433";$link6 = "http://scoblecomments2.scripting.com/comments?u=1011&p=11433&link=http%3A%2F%2Fradio.weblogs.com%2F0001011%2F2005%2F11%2F27.html%23a11433";$text = '<?xml version="1.0" ?><rss version="2.0"> <channel> <title>Scobleizer: Microsoft Geek Blogger</title> <link>' . $link1 . '</link> <description>Robert Scoble\'s look at geek and Microsoft life.</description> <language>en-us</language> <copyright>Copyright 2005 Robert Scoble</copyright> <item> <title>PLEASE SUBSCRIBE TO MY NEW BLOG</title> <link>' . $link2 . '</link> <description> <p> Hello, we know you\'re still subscribed to this blog (9,000 of you are on Bloglines, for instance). So, please unsubscribe from this blog and come over and visit me in my new home at <a href="' . $link3 . '">' . $link3 . '</a> </p> <p> My new RSS feed is here: <a href="' . $link4 . '">' . $link4 . '</a> </p> <p>I have permanently moved over there, so please do come and visit!</p> </description> <guid>' . $link5 . '</guid> <pubDate>Sun, 27 Nov 2005 13:44:16 GMT</pubDate> <comments>' . $link6 . '</comments> </item> </channel></rss>';if ($fp = fopen("aaaa.xml","w")) { fwrite($fp,$text); fclose($fp); echo "XML has been written. <a href=\"aaaa.xml\">View the XML.</a>";} else { echo "could not save";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/18947-creating-an-rss-xml-file-using-php/#findComment-81852 Share on other sites More sharing options...
gardan06 Posted August 30, 2006 Author Share Posted August 30, 2006 it also didnt work, but it wouldnt matter now coz ive finally made it work. thanks anyway Link to comment https://forums.phpfreaks.com/topic/18947-creating-an-rss-xml-file-using-php/#findComment-83060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.