How to Display Data From Rss Feed
RSS - Really Simple Syndication
Building and Using an RSS Feed
by Denis Sureau
What is RSS?
It is a format to share data, defined in the 1.0 version of XML. You can deliver information in this format et one can get this information, and information from other various sources, in this format. Information provided by a website in an XML file is called an RSS feed.
Recent browsers can read directly RSS files, but a special RSS reader or aggregator may be used too.
History
Created by Netscape in 1999. The first version is 0.90. Followed by the 0.91 version that has been improved by the Userland company in 2000.
In 2000 the version 1.0 based on RDF was created by O'Reilly and further maintained by the RSS-DEV group, and named RDF Site Summary.
RSS 2.0 was defined by Dave Winer (previously worker at Userland) at Harvard University in 2002.
This page is based on the Really Simple Syndication, 2.01 specification from Harvard.
Why use RSS?
To get information or news provided by websites in a format computers can process. To display it on a website or to read it yourself.
And for the provider of the content, this allows it to send news about its site.
RSS, how it works?
The RSS system to publish articles and news over the web is very simple:
- There are firstly some web pages, one want to be displayed by other websites.
This set of pages is the RSS feed. - An XML file that defines the RSS feed. This file holds URL, title and summary of each page to display.
- A person which want to read the feed on its computer. He (she) uses an RSS reader or its browser and just adds the feed with the proper command of its software.
- Or another website that wants to display the feed. It has to load the RSS file from the provider, to extract URL of pages, and display titles and summaries. This may be performed by a PHP script.
- When someone visits the website of the receiver, the script is launched, it recalls the RSS file from the provider's website and displays a list of news from extracted data.
- By a click on a line of the list, visitors display a page from the provider.
Structure of an RSS document
It is an XML file and the global container is the "RSS" tag for the 2.0 format.
The file holds one channel at least, this is the website that provides the information.
The channel provides some articles or data. These are web pages from the same site, or from other sites.
How to use RSS?
1 - Using RSS on a desktop
RSS feeds are displayed by browsers. An RSS reader (or aggregator) may also be installed on the operating system (Windows, Linux, Mac OS, etc...). See in resources. There is one that is built with XUL.
Accessing the content depends upon the reader. This may be accomplished just by a click on an "add" button to get the URL of the RSS feed, and let it added to a list of feeds.
2 - Using a feed on a website
The RSS feed is displayed as a list of titles (and optionally summaries). A click on a title displays the new. Titles are updated automatically. A script in PHP or other language, builds the list each time the page is displayed by loading the RSS file and extracting the data from it. Some links to such tools are provided in resources.
How to publish news in an RSS feed?
There are several means to generate RSS feeds.
- Using the RSS library of PHP. A PHP script will build the XML file from titles and descriptions of pages from the content of a page.
- Use a specialized tool to extract the data from a page.
To give access to the XML file, a link is displayed: or
<a type="application/rss+xml" href="https://ww.xul.fr/rss.xml"> RSS feed for this site </a>
Feeds in Atom format use the "application/atom+xml" value instead.
Replace xul.fr by the domain name of your site.
- Feed. It is a set of "item" tags, a set of infos or news.
- RDF. See at the RDF page on this site.
- Syndicated. Published through an RSS feed.
- Syndication. Publishing data by RSS feeds.
rss. The global container.
channel. A distributing channel. It has several descriptive tags and holds one or several items.
<rss version="2.0"> <channel> ... </channel> </rss>
Required tags for the channel
- title. The title of the channel. Should contains the name.
- link. URL of the website that provides this channel.
- description. Summary of what the provider is.
- one item tag at least, for the content.
<rss version="2.0"> <channel> <title>XUL</title> <link>https://www.xul.fr</link> <description></description> <item> ... </item> </channel> </rss>
Optional tags for the channel
- language. The human language used for the text.
- docs. Where to find the doc for the format of the file, may be Harvard.
- webMaster. E-mail.
- pubDate. Publishing date.
- etc. See in the specification for more.
Items of the channel
Each item tag must hold these tags:
- title. Title of the article.
- link. The URL of the page.
- description. Summary of the article.
<item> <title>XUL news</title> <link>https://www.xul.fr/index.php</link> <description>... some text...</description> </item>
And some optional info for this article
- pubDate. Publishing date.
- guid. A string of character that is unique to designate this item.
- category. The category of the article.
- etc.
Building its personal RSS feed, step by step
At start, this is just a simple text file, created with any text editor. But an XML editor is more convenient. (see at the "software" page). The name may be, for example: "feed.xml".
The overall structure is as that:
<?xml version="1.0" ?> <rss version="2.0"> <channel> </channel>
1) Define the source, by the channel tag
The channel will be the same for all your RSS feeds. These tags are required:
- title: the title of your website, may be the one in the title tag of the home page.
- link: the URL of your website: example: https://www.xul.fr
- description: description of your website, about 200 characters, this may be the text assigned to the content attribute of the description tag, in the head section of the home page.
<channel> <title>XUL and XML</title> <link>https://www.xul.fr/en/</link> <description>XML graphical interface etc...</description> </channel>
2) Add an image
This is optional. Design a small image (88x31 for example) in a common format (gif, jpg, png) and put in into the same directory that the RSS file.
The "image" tag is a sub-element of the channel tag
- url is the address of the image itself.
- link is the address of the page displayed when one clicks on the image.
<channel> <title> </title> <link> </link> <image> <url>https://www.xul.fr/xul.gif</url> <link>https://www.xul.fr/en/index.php</link> </image> </channel>
3) Add a new
Now, we will add a web page to display an information. This is an "item" tag, a sub-element of channel, and this components are required:
- title: the title of the article.
- link: the URL of the page.
- description: a summary of the article, about 200 characters.
<item> <title>News of today</title> <link>https://www.xul.fr/en-xml-rss.html</link> <description>All you need to know about RSS</description> </item>
4) Add more items
More items may be added to this channel.
5) Upload the file
Put the feed.xml file into your website, among other web pages.
6) Validate the file
You may use this online RSS feed validator.
7) Make it available
This is accomplished by adding an RSS button on the home page. A click on the button should display the XML file you have created.
<a href="https://www.xul.fr/rss.xml"> <img src="rss.gif"> </a>
If the image is not displayed, use a complete URL, as https://www.xul.fr/rss.gif, for example.
8) Updating the feed
To publish further articles, you have just to add items, and remove older ones to keep the number of articles constant.
Example: the complete file
<?xml version="1.0" ?> <rss version="2.0"> <channel> <title>Ajax and XUL</title> <link>https://www.xul.fr/en/</link> <description>XML graphical interface etc...</description> <image> <url>https://www.xul.fr/xul-icon.gif</url> <link>https://www.xul.fr/en/index.php</link> </image> <item> <title>News of today</title> <link>https://www.xul.fr/en-xml-rss.html</link> <description>All you need to know about RSS</description> </item> <item> <title>News of tomorrows</title> <link>https://www.xul.fr/en-xml-rdf.html</link> <description>And now, all about RDF</description> </item> </channel> </rss>
You can download the example and use it as a template, by replacing of course, xul.fr, by the name of your website.
How browsers know there is an RSS feed on a website
You have created an RSS feed and it is now stored at root of your website. You must let browsers knowing the existence of this file and its location, when they enter and display the home page (or any other page if you want). Firefox will display the feed icon into the URL field, Internet Explorer on the bar of commands.
To activate them, insert the following line into the source code of the page, anywhere inside the <head> </head> section:
<link rel="alternate" type="application/rss+xml" href="https://www.xul.fr/rss.xml" title="Your title">
Replace the URL by your domain name with the path and filename of your RSS feed.
And if the file is in the atom format, replace rss+xml by atom+xml.
Translations
- French.
Specifications and tools |
---|
Specification and documents
- RSS 2.0 specification. Defined by Harvard.
- RSS 1.0 Tutorial.
Tools to generate and display RSS feeds
- Ara Editor. Online RSS generator and editor, written in PHP.
- RSS Reader. PHP function to display an RSS feed on a Web page, from a local or remote file.
Forum
How can I set up to receive RSS for jobs from various sites?
Fri, 01 Aug 2008 10:52:32
jobman001
Hi, I just discovered RSS feeds. How can I set up to receive RSS feeds from various sites? Is there a site I can go to for instruction? I'm specifically interested in job updates that companies post on their sites. Thanks.
Mon, 04 Aug 2008 15:43:05
Administrator
Hello, If you goal is just to be informed about news or jobs, you should use an aggregator that is connected to the RSS feed you choose, and that is updated automatically. A such tool is listed above. You can get much tools by a google search: rss + aggregator Once the software downloaded you have to add all the feeds you want, and you can also visit sites and click on the RSS button (radio) in the URL bar to display the feed. You are then prompted to subscribe to the feed.
© 2006-2022 Denis Sureau & Xul.fr
donnellyprommeaveris.blogspot.com
Source: https://www.xul.fr/en-xml-rss.html
0 Response to "How to Display Data From Rss Feed"
Post a Comment