Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome rendering XML as text for RSS feed

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;  ?> 
like image 718
Scott Avatar asked Nov 01 '09 07:11

Scott


People also ask

How do I get an RSS feed from XML?

Click on Load, enter RSS feed URL and it will output XML data on the left side and HTML data on the right side. This tool also supports to convert RSS XML to JSON. Show activity on this post. If you view the feed in Firefox it'll read like an RSS reader, but if you view the source code you've got it in XML format.

How do I render XML in Chrome?

Just about every browser can open an XML file. In Chrome, just open a new tab and drag the XML file over. Alternatively, right click on the XML file and hover over "Open with" then click "Chrome". When you do, the file will open in a new tab.

Is RSS in XML format?

RSS is a Web content syndication format. Its name is an acronym for Really Simple Syndication. RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.

Does Google Chrome support RSS feeds?

You can follow a site through the browser's three-dot menu to subscribe to its RSS feed and have it update in your Chrome app. Sites you're following will appear in a tab called “following,” which sits along Google's “for you” tab of recommended articles.


2 Answers

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.

like image 96
Wedge Avatar answered Sep 20 '22 17:09

Wedge


I had this same problem and I used "application/xml" and it fixed it right up. Chrome doesn't like "application/rss+xml".

like image 24
Andrew Christensen Avatar answered Sep 17 '22 17:09

Andrew Christensen