MySQL
  Home arrow MySQL arrow Page 3 - Creating an RSS Reader: the Reader
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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: starstarstarstarstar / 10
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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
     

       

    MYSQL ARTICLES

    - MySQL Security Tips
    - Designing a MySQL Database: Tips and Techniq...
    - The Three Most Important MySQL Queries
    - Null and Empty Strings
    - MySQL Server Tuning Tips and Tricks
    - MySQL Query Optimizations and Schema Design
    - MySQL Benchmarking Tools and Utilities
    - MySQL Benchmarking Concepts and Strategies
    - Take Some Load off MySQL with MemCached
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT