MySQL
  Home arrow MySQL arrow Page 3 - Creating an RSS Reader: the Reader
The Best Selling PC Migration Utility.
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Creating an RSS Reader: the Reader
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2007-02-06

    Table of Contents:
  • Creating an RSS Reader: the Reader
  • XML-related Functions
  • The Meat of the Code
  • Reading RSS Data from a Database (Optional)

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Dell PowerEdge Servers

    Creating an RSS Reader: the Reader - The Meat of the Code
    (Page 3 of 4 )

    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",  
               xml_error_string(xml_get_error_code($xml_parser)),  
               xml_get_current_line_number($xml_parser)));

      }

      

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


       · Hope you enjoyed my article. Any comments are very welcome
       · thank you for this tutorial,it's very detail and easy understand,but i think...
     

       

    MYSQL ARTICLES

    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...
    - Creating the Blog Script for a PHP/MySQL Blo...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway