Google Chrome rendering XML as text for RSS feed

Scott picture Scott · Nov 1, 2009 · Viewed 22.4k times · Source

I have this script to generate an XML file for an RSS feed. Works great in every browser except Chrome. Chrome just renders the XML as text. Something to do with header("Content-Type: application/rss+xml; charset=ISO-8859-1"); possibly?

This is the code I'm using:

<?php

$linkUp = "http://localhost/sites/myBlog/";

header("Content-Type: application/rss+xml; charset=ISO-8859-1");

$rssfeed  = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$rssfeed .= '<rss version="2.0">';
$rssfeed .= '<channel>';
$rssfeed .= '<title>Mytitle</title>';
$rssfeed .= '<link>' . $linkUp . '</link>';
$rssfeed .= '<description>Mydescription</description>';
$rssfeed .= '<language>en-us</language>';
$rssfeed .= '<copyright>&copy; ' . strftime('%Y') .  ' . " " . ' . $linkUp . '</copyright>';


$query = "SELECT * FROM rss";
$result = $db->query($query);

while($row = $db->fetch_array($result)) {

    $rssfeed .= '<item>';
    $rssfeed .= '<title>' . $row['rss_title'] . '</title>';
    $rssfeed .= '<description>' . $row['rss_description'] . '</description>';
    $rssfeed .= '<link>' . $row['rss_link'] . '</link>';
    $rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O", strtotime($date)) . '</pubDate>';
    $rssfeed .= '</item>';
}

$rssfeed .= '</channel>';
$rssfeed .= '</rss>';

echo $rssfeed;

?>

Answer

Wedge picture Wedge · Nov 1, 2009

This is a known bug in chrome that has yet to be fixed, chrome does not display xml rss feeds with any formatting whatsoever.

Update: There is now an RSS subscription / reader extension for Chrome.