XML
  Home arrow XML arrow Page 4 - Creating an RSS Reader Application
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 
eWeek
 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: 4 stars4 stars4 stars4 stars4 stars / 7
    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:
      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

    Ziff Davis Enterprise Virtual Tradeshows: Hot Topics, Cutting Edge Technology, Real-time Networking among IT Professionals. Learn more

    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.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hope you enjoyed my article. Any comments are very welcome
     

       

    XML ARTICLES

    - 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...
    - SimpleXML
    - XForms Basics, Part 3
    - XForms Basics, Part 2
    - XForms Basics




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