Omnimaga

General Discussion => Technology and Development => Web Programming and Design => Topic started by: squidgetx on October 17, 2011, 04:02:56 pm

Title: rss feed?
Post by: squidgetx on October 17, 2011, 04:02:56 pm
So I'm trying to make an rss feed, and my problem isn't with the formatting, or the php, or anything. I've got it at the point where the php outputs what should be proper rss xml, but I don't know how to get the browser to realize that it's an xml file, not html.
Code: (What you see) [Select]
http://domain.comdescriptionendomain.com/1.pngDesc1domain.com/1.pngDesc2
Code: (What you see when you hit view page source) [Select]
<?xml version="1.0" encoding="utf-8"?>
<rss version='2.0'><channel><title>Title</title><link>http://shakespearescomics.tk</link><description>description</description><language>en</language><item><title>Title1</title><link>domain.com/1</link><description>Desc1</description></item>...etc.

So the output of the php isn't wrong, but the browser can't detect that it's xml because the file is named 'rss.php.' I tried using Apache's .htaccess to treat xml as php but that doesn't work either... (AddType application/x-httpd-php .xml) I also tried adding 'Content-Type: application/xml' at the beginning of the file but that didn't seem to work either..

 
Title: Re: rss feed?
Post by: Ikkerens on October 17, 2011, 04:27:30 pm
Code: (php) [Select]
<?php

header
(&#39;Content-Type: text/rss&#39;); //Or text/xml, either should be fine

?>

Title: Re: rss feed?
Post by: Deep Toaster on October 17, 2011, 05:01:45 pm
If that doesn't work, you can use .htaccess to rewrite "rss.xml" into loading "rss.php."
Title: Re: rss feed?
Post by: squidgetx on October 17, 2011, 05:38:40 pm
Got 'em. Thanks guys.