2010-09-04 11 views
4

je suis en train de faire un simple flux rss mais le problème est quand je lance le fichier est dit voulez-vous ouvrir rss.php ...simples rss feed

ici est le code im peut-être faire quelque chose de mal ? Je l'ai mis dans ce format juste pour le voir fonctionner.

<?php 
header('Content-Type: application/rss+xml; charset=utf-8'); 
?> 
&#60;?xml version='1.0' encoding='ISO-8859-1'?&#62; 
<rss version='2.0'> 
<channel> 
<title>feed title</title> 
<description>this is my example</description> 
<link>http://localhost:8888/redline</link> 
<copyright>Copyright (C) 2010 sarmenhb</copyright> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item>  
</channel> 
</rss> 

Répondre

11

Vous devez générer le vrai <?xml version='1.0' encoding='ISO-8859-1'?>, pas une version autorisée. Comme il est problématique en raison de php propre <?, echo après l'en-tête:

<?php 
//header('Content-Type: application/xml'); 
header('Content-Type: application/rss+xml; charset=utf-8'); 
echo '<?xml version="1.0" encoding="utf-8"?>'; 
?> 
<rss version='2.0'> 
<channel> 
<title>feed title</title> 
<description>this is my example</description> 
<link>http://localhost:8888/redline</link> 
<copyright>Copyright (C) 2010 sarmenhb</copyright> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item> 
<item> 
<title>Example 1</title> 
<description>This is the description of the first example.</description> 
<link>http://www.example.com/example1.html</link> 
<pubDate>Mon, 29 Dec 2008 22:10:00 -0600</pubDate> 
</item>  
</channel> 
</rss> 
+1

je dois parfaire mes compétences vitesse de frappe sur ce MacBook, je viens de recevoir. +1 – BoltClock