ukweb Posted September 13, 2008 Share Posted September 13, 2008 Hi folks! I have the following script which generates a RSS xml document; // Update the XML file for Blog RSS mysql_select_db($database_sql, $sql); $query_all_blogs = "SELECT * FROM blog_posts ORDER BY blog_id DESC"; $all_blogs = mysql_query($query_all_blogs, $sql) or die(mysql_error()); $row_all_blogs = mysql_fetch_assoc($all_blogs); $totalRows_all_blogs = mysql_num_rows($all_blogs); $pre_desc = cut_text($row_all_blogs['text'], 200)."..."; $desc = strip_tags($pre_desc); $file = fopen($blog_xml, 'w'); $xml_head = "<?xml version=\"1.0\"?> <rss version=\"2.0\"> <channel> <title>".$company."'s Blog Powered by SJWright.co.uk Site Editor</title> <link>http://www.".$site."</link> <description>Find out what we've been up to!</description> <language>en-uK</language>\n"; fwrite($file, $xml_head); do { $xml_body = "<item> <title>".$row_all_blogs['title']."</title> <link>http://www.".$site."/?this_page=blog&id=".$row_all_blogs['uni_id']."</link> <description>".$desc."</description> </item>\n"; fwrite($file, $xml_body); } while ($row_all_blogs = mysql_fetch_assoc($all_blogs)); $xml_close = "</channel> </rss>"; fwrite($file, $xml_close); fclose($file); $success = $success."XML RSS File Generated Successfully"; The outputted file can be found at http://allturf.co.uk/xml/blog.xml When the documet is opened with firefox it doesnt list the items, and when I validate it using a W3C validator it fails but i cant see why. http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fallturf.co.uk%2Fxml%2Fblog.xml Any ideas? This is my first go at XML and generating a XML document, apologies if the solution is a simple one. Link to comment https://forums.phpfreaks.com/topic/124056-solved-generating-rss-xml-document-with-php-but-feed-does-not-work/ Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 Use htmlentities(). Link to comment https://forums.phpfreaks.com/topic/124056-solved-generating-rss-xml-document-with-php-but-feed-does-not-work/#findComment-640443 Share on other sites More sharing options...
ukweb Posted September 13, 2008 Author Share Posted September 13, 2008 it didnt work, it just changed the document into something that would not validate at all. This is why I cant understand it because it seems to be coded correctly. Link to comment https://forums.phpfreaks.com/topic/124056-solved-generating-rss-xml-document-with-php-but-feed-does-not-work/#findComment-640451 Share on other sites More sharing options...
ukweb Posted September 13, 2008 Author Share Posted September 13, 2008 done it now thanks! I used htmlentities() as suggested just on links and it works a treat! Thanks DarkWater Link to comment https://forums.phpfreaks.com/topic/124056-solved-generating-rss-xml-document-with-php-but-feed-does-not-work/#findComment-640453 Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 No problem. Link to comment https://forums.phpfreaks.com/topic/124056-solved-generating-rss-xml-document-with-php-but-feed-does-not-work/#findComment-640471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.