Click to See Complete Forum and Search --> : RSS and PHP


KevinM2k
07-01-2005, 09:54 AM
Hi, this is my first post, hope someone can help, im trying to learn rss, i've managed to create an xml file successfully however I want to be able to create an xml file using php, i have teh following code:

<?php
header("content-type: text/xml");
?>

<?xml version="1.0" encoding="iso-8859-15"?>
<?xml-stylesheet type="text/css" href="feed_rss.css" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">

<channel>

<title>Test Article</title>
<description>Test Description</description>
<language>en</language>
<link>http://www.test.com</link>";

<item>
<title>test</title>
<description>est</description>
<link>http://www.test.com/articles.php?</link>
</item>

</channel>
</rss>

This isn't working, can someone explain why this is?

Thanks

Kevin

pyro
07-01-2005, 10:43 AM
I see at least two problems, right off:

You have no <item> around you first set of values, and you have "; after you first </link>

ShrineDesigns
07-01-2005, 12:28 PM
if i remember correctly, <link></link> in <item></item> should be <guid></guid> for rss 2.0

pyro
07-01-2005, 01:06 PM
Both are fine: http://feedvalidator.org/docs/rss2.html#hrelementsOfLtitemgt

ShrineDesigns
07-01-2005, 05:20 PM
oh, i was goning by the recommendation from harvard.edu, must be out of date lol

KevinM2k
07-04-2005, 02:57 AM
The first one doesn't need an <item> tag around it, as its the very first one... the descriptive one, from what i've seen in other xml scripts this is how its done, its only the actual news items that are in the <item> tags.

Ive moved the "; at the end of one of the lines, but still i'm getting nothing at all.

The code is now as follows:

<?php
header("content-type: text/xml");
?>

<?xml version="1.0" encoding="iso-8859-15"?>
<?xml-stylesheet type="text/css" href="feed_rss.css" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">

<channel>

<title>Test - Articles - Newsfeed</title>
<description>Test Desc</description>
<language>en</language>
<link>http://www.test.com</link>

<item>
<title>name</title>
<description>intro</description>
<link>http://www.test.com/articles.php?</link>
</item>

</channel>
</rss>

Ive tried putting <item> tags around the first one too but that makes no difference.

Kev

KevinM2k
07-04-2005, 03:10 AM
I've just been thinking about it actually... maybe the above code is ok? The problem I'm having is displaying it on a webpage. Im using the rss2html.php script, can this script only accept xml files? I'm unsure I would have thought it wouldn't matter, but it would be nice to clear that up. Does anyone have any other scripts that run rss on a website. RSS2HTML is easy but if it doesn't support .php extensions instead of .xml it won't be of any use to me.

Thanks