Home arrow MySQL arrow Creating an RSS Reader: the Reader

Creating an RSS Reader: the Reader

In this article we are going to discuss how to create a PHP-based RSS reader. It would be helpful if you know something about XML, but not really necessary. RSS documents have three main tags: Title, Link and Description. And they all do exactly what their names suggest. I will go into detail about these tags in my second article dealing with “building an RSS file.” For now, we will only focus on the “reading” part of the article.

TABLE OF CONTENTS:
  1. Creating an RSS Reader: the Reader
  2. XML-related Functions
  3. The Meat of the Code
  4. Reading RSS Data from a Database (Optional)
By: Jacques Noah
Rating: starstarstarstarstar / 16
February 06, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

A downloadable file is available for this article.

As an extra I will introduce a database aspect of the reader. We will use the database to store and retrieve the latest stories. To continue with this article you will need PHP 4 and higher and optionally MYSQL.

Below is an example text from an RSS document:

                            Start example text

<item>

      <title>First example</title>

      <link>www.mylink.com/someplace.html</link>

            <description>Some description, blah,blah,blah
</description>

    </item>

    <item>

      <title>Thousands set to attend todays celebration</title>

      <link>http://
www.mylink.com/someplace.html /NewsTopStories?m=318</link>

      <description>blah,blah,blah </description>

    </item>

                             End example text

Code

To create an RSS Reader in PHP, we need to:

  1. Create a function to read the start tag (start element).
  2. Create a function to read the end tag (endElement).
  3. Create function to read the text associated with the tags.

A typical RSS document will have the following structure: 

<RSS>

    <channel>

         <item>

        </item>

   </channel>

</RSS>

A start tag is a tag without the “/” character, for example: <items>. An end tag is a tag with the “/” character, for example: </item>.

So the start and end tag functions will search for the “<item></item>” tags and once they have found those, it will be a simple matter of retrieving the text data from them to display.



 
 
>>> More MySQL Articles          >>> More By Jacques Noah
 

blog comments powered by Disqus
   

MYSQL ARTICLES

- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users
- Continuent and SkySQL Form Partnership, Hado...
- Oracle Releases MySQL Cluster 7.2
- Cloudera Named Enterprise Hadoop Leader
- Xeround Releases Free Version of MySQL Cloud...
- Oracle Announces New MySQL Specialization
- Constant Contact Chooses SkySQL for MySQL Su...
- Revoke Statement in MySQL
- The Grant Statement in MySQL
- SuccessBricks Announces ClearDB Availability...


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap

Dev Shed Tutorial Topics: