Home arrow MySQL arrow Page 3 - Creating an RSS Reader: the Reader

The Meat of the Code - MySQL

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.

  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



Now that we have created the required functions, let's continue with the meat of the code:

function parsefile($RSSfile){

  // Create an xml parser

  $xmlParser = xml_parser_create();

  // Set up element handler

  xml_set_element_handler( $xmlParser, "startTag", "endTag" );


  // Set up character handler

  xml_set_character_data_handler( $xmlParser, "TxtTag" );

  // Open connection to RSS XML file for parsing.

  $fp = fopen( $RSSfile,"r" )

    or die( "Cannot read RSS data file." );


  // Parse XML data from RSS file.

  while( $data = fread( $fp, 4096 ) ) {

    xml_parse( $xmlParser, $data, feof( $fp ) );

or die(sprintf("XML error: %s at line %d",  



  // Close file open handler

  fclose( $fp );

  // Free xml parser from memory

  xml_parser_free( $xmlParser );


The above function calls both the startTag/endTag functions to loop through the XML file and displays the contents.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: