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
escort Bursa Bursa escort Antalya eskort
   

MYSQL ARTICLES

- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- 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

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: