XML
  Home arrow XML arrow Page 4 - Creating an RSS Reader Application
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? 
XML

Creating an RSS Reader Application
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 11
    2007-02-20


    Table of Contents:
  • Creating an RSS Reader Application
  • Code
  • Parsing the RSS document
  • Creating an enhanced RSS document

  • 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 Application - Creating an enhanced RSS document
    ( Page 4 of 4 )

    If your choice was to create an Enhanced version, a function called efrm() is called which displays a form that requests particular info from you. Below is a screen shot of the form and after that is shown the actual function code:

    Fig 4. Enhanced RSS Document information form...

    function enhancedfrm(){
     
    echo '<form id="form1" name="form1" method="post"
    action="' .$_SERVER['PHP_SELF'].'?action=efrm">
      
    <table width="82%" border="0" cellspacing="1">
        <tr>
          <td colspan="4" valign="top" bgcolor="#999999"><strong>All
    information on this form is required: </strong></td>
        </tr>
        <tr>
          <td valign="top"><strong>Title</strong></td>
          <td><input name="mtitle" type="text" size="40" /></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td valign="top"><strong>Link</strong></td>
          <td><input name="mlink" type="text" size="40" /></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td valign="top"><strong>Description</strong></td>
          <td><textarea name="mdesc" cols="40"
    rows="5"></textarea></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td width="18%" bgcolor="#999999">&nbsp;</td>
          <td width="33%" bgcolor="#999999">&nbsp;</td>
          <td width="11%" bgcolor="#999999">&nbsp;</td>
          <td width="38%" bgcolor="#999999">&nbsp;</td>
        </tr>
        <tr>
          <td valign="top"><strong>Managing Editor: </strong></td>
          <td valign="top"><input name="me" type="text" id="me"
    size="40" /></td>
          <td valign="top"><strong>URL:</strong></td>
          <td valign="top"><input name="imgURL" type="text"
    id="imgURL" size="40" /></td>
        </tr>
        <tr>
          <td valign="top"><strong>Web Master: </strong></td>
          <td valign="top"><input name="wm" type="text" id="wm"
    size="40" /></td>
          <td valign="top"><strong>Title:</strong></td>
          <td valign="top"><input name="imgTitle" type="text"
    id="imgTitle" size="40" /></td>
        </tr>
        <tr>
          <td valign="top"><strong>Publication Date: </strong></td>
          <td valign="top"><input name="pubdate" type="text"
    id="pubdate" size="40" /></td>
          <td valign="top"><strong>Link:</strong></td>
          <td valign="top"><input name="imgLink" type="text"
    id="imgLink" size="40" /></td>
        </tr>
        <tr>
          <td valign="top"><strong>Last Build Date: </strong></td>
          <td valign="top"><input name="bdate" type="text" id="bdate"
    size="40" /></td>
          <td valign="top"><strong>Width:</strong></td>
          <td valign="top"><input name="width" type="text" id="width"
    size="30" /></td>
        </tr>
        <tr>
          <td valign="top"><strong>Generator:</strong></td>
          <td valign="top"><input name="gen" type="text" id="gen"
    size="40" /></td>
          <td valign="top"><strong>Height:</strong></td>
          <td valign="top"><input name="height" type="text"
    id="height" size="30" /></td>
        </tr>
        <tr>
          <td valign="top"><strong>Docs:</strong></td>
          <td valign="top"><input name="docs" type="text" id="docs"
    size="40" /></td>
          <td valign="top">&nbsp;</td>
          <td valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td valign="top"><strong>CopyRight Notice: </strong></td>
          <td valign="top"><input name="cright" type="text"
    id="cright" size="40" /></td>
          <td valign="top">&nbsp;</td>
          <td valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td valign="top"><strong>Language:</strong></td>
          <td valign="top"><input name="lang" type="text" id="lang"
    size="40" /></td>
          <td valign="top">&nbsp;</td>
          <td valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#666666">&nbsp;</td>
          <td bgcolor="#666666">&nbsp;</td>
          <td bgcolor="#666666">&nbsp;</td>
          <td bgcolor="#666666">&nbsp;</td>
        </tr>
        <tr>
          <td><strong>Title:</strong></td>
          <td><input name="t1" type="text" id="t1" size="40" /></td>
          <td><strong>Title:</strong></td>
          <td><input name="t2" type="text" id="t2" size="40" /></td>
        </tr>
        <tr>
          <td><strong>Link:</strong></td>
          <td><input name="l1" type="text" id="l1" size="40" /></td>
          <td><strong>Link:</strong></td>
          <td><input name="l2" type="text" id="l2" size="40" /></td>
        </tr>
        <tr>
          <td valign="top"><strong>Description:</strong></td>
          <td><textarea name="d1" cols="40" rows="5"
    id="d1"></textarea></td>
          <td valign="top"><strong>Description:</strong></td>
          <td valign="top"><textarea name="d2" cols="40" rows="5"
    id="d2"></textarea></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><input type="submit" name="Submit" value="Submit" /></td>
          <td>&nbsp;</td>
        </tr>
      </table>';
    echo '</form>';
    }

    Once you've submitted this form, the do_efrm function is called. The purpose of this function is to create the RSS document with the information that you supplied in the form. The function is shown below:

    function do_efrm($filename,$mtitle,$mlink,$mdesc,$me,$wm,
    $cright,$lang,$pubdate,$builddate,$gen,$docs,$imgurl,$imgtitle,
    $imglink,$t1,$l1,$txt1,$t2,$l2,$txt2){
     
    //Create the file
     
    if($fp = fopen($filename,"a+")){
       
    fwrite($fp,"<?xml version='1.0'?>rn");
       
    fwrite($fp,"<rss version='2.0' >rn");
       
    fwrite($fp,"<channel>rn");
       
    fwrite($fp,"<title>".$mtitle."</title>rn");
       
    fwrite($fp,"<link>".$mlink."</link>rn");
       
    fwrite($fp,"<description>".$mdesc."</description>rn");
       
    fwrite($fp,"<managingEditor>".
               $me."</mangagingEditor>rn");
       
    fwrite($fp,"<webMaster>".$wm."</webMaster>rn");
       
    fwrite($fp,"<copyright>".$cright."</copyright>rn");
       
    fwrite($fp,"<language>".$lang."</language>rn");
       
    fwrite($fp,"<pubdate>".$pubdate."</pubdate>rn");
       
    fwrite($fp,"<lastbuilddate>".
               $builddate."</lastbuilddate>rn");
       
    fwrite($fp,"<generator>".$gen."</generator>rn");
       
    fwrite($fp,"<docs>".$docs."</docs>rn");
       
    fwrite($fp,"<image>rn");
       
    fwrite($fp,"<url>".$imgURL."</url>rn");
       
    fwrite($fp,"<title>".$imgtitle."</title>rn");
       
    fwrite($fp,"<link>".$imglink."</link>rn");
       
    fwrite($fp,"</image>rn");
       
    fwrite($fp,"<item>rn");
        
    fwrite($fp,"<title>".$t1."</title>rn");
       
    fwrite($fp,"<link>".$l1."</link>rn");
       
    fwrite($fp,"<description>".$txt1."</description>rn");
       
    fwrite($fp,"</item>rn");
       
    fwrite($fp,"<item>rn");
       
    fwrite($fp,"<title>".$t2."</title>rn");
       
    fwrite($fp,"<link>".$l2."</link>rn");
       
    fwrite($fp,"<description>".$txt2."</description>rn");
       
    fwrite($fp,"</item>rn");
       
    fwrite($fp,"</channel>rn");
       
    fwrite($fp,"</rss>");
       
    fclose($fp);
       
    echo "The RSS document <b>" .$filename. "</b> has been created and stored.";
      
    }else{
       
    echo "The file could not be created due to a system error";
     
    }
    }

    There you have it! You can now read and create as many RSS documents as you like!

    Conclusion

    Although this program fulfills its basic aim of creating RSS files, it nevertheless needs some improvements, especially in the area of checking submitted form data. This is important because you do not want to create files with no information. Also, I've not done a lot as far as the application design is concerned, because I only wanted to focus on the programming code as opposed to its design. But the building blocks are there for you to create the design to your taste.



     
     
    >>> More XML Articles          >>> More By Jacques Noah
     

       

    XML ARTICLES

    - Flex Array Collection Sort and Filtering
    - The Flex Tree Control
    - Flex List Controls
    - Working with Flex and Datagrids
    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...





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