| | |
How to use RSS?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2005
Posts: 32
Reputation:
Solved Threads: 0
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>
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/
•
•
•
•
Originally Posted by steven01
sorry,I don't familiar with it.Can you give me some codes or how to do in dreamweaver?
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:
[HTML]<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>[/HTML]
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]<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
}
?>[/PHP]
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.
Last edited by digital-ether; Dec 29th, 2005 at 6:58 am. Reason: typo in code
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- Where are the good Java RSS Feeds? (IT Professionals' Lounge)
- How do I put a blog RSS feed in PHPBB? (PHP)
- How to use this site's RSS feed? (DaniWeb Community Feedback)
- RSS Feed Readers (Geeks' Lounge)
- Rss Feeds! (RSS, Web Services and SOAP)
- RSS Feed (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: Image Resize Function Error
- Next Thread: createimagefromjpeg(?)
| Thread Tools | Search this Thread |
.htaccess alexa apache api array beginner beneath binary broadband broken cakephp checkbox class cms code convert cron curl database date display dynamic echo email emptydisplayvalue encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert ip javascript joomla key keywords limit link login mail mail() memberships menu mlm multiple multipletables mysql mysql_real_escape_string network oop open passwords paypal pdf php provider query radio random redirect remote rss script search securephp server sessions smtp source space sql strip_tags syntax system table template tutorial update upload url user validator variable video voteup web youtube






