Jump to content

[SOLVED] Generating rss xml document with php but feed does not work!


ukweb

Recommended Posts

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.