Hi,I want to use RSS at my site.How to do so the contennent can be displayed at my site?This is the code:I want to use RSS at my site,how to do in dreamweaver?
This is the code:


Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
- <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <channel>
<title>WeakGame Entertainment</title>
<link>weakgame.com</link>
<lastbuilddate>Sun, 25 Dec 2005 04:15:31 -0500</lastbuilddate>
<description>The latest posts on WeakGame.com</description>
<language>en-us</language>
- <item>
<title>No Santa</title>
<link>http://www.weakgame.com/?show=5594</link>
<description />
<dc:date>Sun, 25 Dec 2005 00:00:00 -0500</dc:date>
</item>
- <item>
<title>The "L" Word</title>
<link>http://www.weakgame.com/?show=5593</link>
<description />
<dc:date>Sun, 25 Dec 2005 00:00:00 -0500</dc:date>
</item>
- <item>
<title>Peter Griffin Christmas</title>
<link>http://www.weakgame.com/?show=5592</link>
<description />
<dc:date>Sun, 25 Dec 2005 00:00:00 -0500</dc:date>
</item>
- <item>
<title>Get Rid of Wifey</title>
<link>http://www.weakgame.com/?show=5585</link>
<description>A funny McDonalds commercial that shows us how to get rid of the wife</description>
<dc:date>Sun, 25 Dec 2005 00:00:00 -0500</dc:date>
</item>
- <item>
<title>Ref Knock-out</title>
<link>http://www.weakgame.com/?show=5560</link>
<description>Lucky this wasnt a championship match or else the red would be walking away with a belt around his waist.</description>
<dc:date>Sat, 24 Dec 2005 00:00:00 -0500</dc:date>
</item>
</channel>
</rss>

You need an RSS parser. There are many available, or you can easily write one yourself in not too much time, but one that I am particularly fond of is called MagpieRSS. You can get it at: http://magpierss.sourceforge.net/

sorry,I don't familiar with it.Can you give me some codes or how to do in dreamweaver?

sorry,I don't familiar with it.Can you give me some codes or how to do in dreamweaver?

HI steven01

RSS is a way of syndicating site content.
The RSS file is an xml file with the RSS specification. That means its written to follow rules layed out for all RSS files. This allows any website or application to read the RSS file if it knows the RSS specification.

To use an RSS file, you have to have an application that will parse the RSS file.
This typically means, changing the xml in the RSS file, into HTML for display on your website.

So essentially what you have to do is:

1) know the RSS file location. http://somesite.com/rss.xml
2) Read the RSS files
3) Change each RSS tag ito a html tag.
4) Show this changes on your website.

So for example the xml:

<item>
<title>No Santa</title>
<link>http://www.weakgame.com/?show=5594</link>
<description />
<dc:date>Sun, 25 Dec 2005 00:00:00 -0500</dc:date>
</item>

Can be parsed and show on your website as:

No Santa at Sun, 25 Dec 2005 00:00:00 -0500

- As you can see, the xml is just information, that you can display on your website. How you display this information, is up to you.

As for using dreamweaver.
Id go with using magpie: http://magpierss.sourceforge.net/
Or simply writing my own php code.
Dreamweaver id for formatting your code (making it easier to view), not writing code.

OK i'll write a simple php script to demonstrate how to read/parse RSS: (This is a very simple regex replacement, nothing standard)

This sample just lists the titles from an rss feed:

<php

$rssUrl = "http://somesite.com/rss.xml"; // change this to the url of the rss file
$rss_array = file($rssUrl); // retrieve the file to an array
$rss = implode("\n", $rss_array); // implode the array to string

$titles = preg_match_all("/<title>(.*)</title>/", $rss, $matches); // match all the titles using a regex expression

// iterate through all matches
foreach ($matches as $title) {
   echo $title[1]."<br />"; // display the title
}

?>

I havent tested the above code.
But it should clue you in.
preg_match_all is a regex expression (regular expression). You can seach google on that. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.