Copyright © 2004 by Lawrence Ragan Communications, Inc. and reprinted from the April, 2004 issue of FoxTalk with permission of the publisher. For more information on FoxTalk, please visit www.pinnaclepublishing.com.


RSS: XML Publish and Subscribe Using Visual FoxPro

By Ted Roche
RSS (Really Simple Syndication) is an up-and-coming XML document format used for Internet news subscriptions and for publishing your own news to fellow developers or customers. In this article, Ted Roche gives an overview of what the format looks like and what tools are available, and provides some ideas that a clever FoxPro programmer might use with RSS.

If you frequently surf to online news sites or Weblogs, or if you're a fan of e-mail newsletters like LockerGnome, you've probably seen the distinctive orange "XML" icon. Sites like InfoWorld.com, O'Reilly & Associates, and Hentzenwerke Publishing offer news feeds via a technology with the acronym of RSS. RSS is a form of XML document used to notify subscribers of changes to Web sites, mailing lists, and news feeds and to summarize those changes. Depending on who you ask, RSS stands for RDF Site Summary, Rich Site Summary, or Really Simple Syndication, but for our purposes, it stands for opportunity.

In this article, I'll show you why RSS is a useful format for you to use as a consumer to keep up with news in the Visual FoxPro community and the computing industry. First, let's go read some RSS, write some RSS, and then come back and figure out what we did.

Navigating to www.tedroche.com/FoxWikiRSS/FoxWikiRSS20.xml will display a document similar to the source shown in Listing 1. Note that the document is an XML document, is generated by Visual FoxPro, and lists the title, description, and link for an updated topic ("Enginebehavior") on the FoxForum Wiki Web site.

Listing 1. An RSS 2.0 news feed for the FoxForum Wiki site.


 
<!--  RSS generated by Visual FoxPro 08.00.0000.2521 EXE Support Library for Windows on Fri, 23 Jan 2004 19:48:03 GMT--> 
<rss version="2.0">
<channel>
  
 http://fox.wikis.com/ 
 <description>KnowledgeBase and Community about Visual 
   FoxPro</description> 
 <language>en-us</language> 
 <copyright>Copyright 2002 by the authors</copyright> 
 <lastbuilddate>Fri, 23 Jan 2004 19:48:03 GMT
    </lastbuilddate> 
 <docs>http://blogs.law.harvard.edu/tech/rss</docs> 
 <generator>Visual FoxPro 08.00.0000.2521 EXE Support 
    Library for Windows</generator> 
 <category domain="Syndic8">23766</category> 
 <ttl>40</ttl> 
   <item>
     
     <description><!--[CDATA[In VFP8, some SQL Selects
      may not work that worked in 7 due to a rules change
      on the GROUP BY clause.One way around it is to:set
      enginebehavior to 70in code,Or, in the config.fpw
      add:SET ENGINEBEHAVIOR=70PeterDiotte]]--></description>
     http://fox.wikis.com/wc.dll?Wiki~Enginebehavior
       
     <guid>http://fox.wikis.com/wc.dll?Wiki~Enginebehavior
       </guid>
     <pubdate>Fri, 23 Jan 2004 19:07:51 GMT</pubdate>
   </item>
</channel>
</rss>

You're now an RSS consumer! The reality is, for a single article it's far simpler to go to Steven Black's Web site and read what's new than it is to try to unscramble the XML document. However, if you were subscribed to the FoxForum Wiki RSS feed and the ComputerWorld Web feed and the CNET News feed, and if you had a reader more suited to the task than Notepad, you'd be in business!

And a business it is. There are dozens, if not hundreds, of RSS readers that make the task or gathering, sorting, and presenting breaking news stories easy for you to view. (See the "Resources" sidebar at the end of this article for a list of RSS readers.) RSS news aggregation is a fantastic way to make the 30-second compiles of your project more productive–Alt-Tab to your news aggregator and all the latest news is sitting there waiting for you. RSS news readers are available for every platform (Mac OS X, Windows, Linux) and in many different languages. Some are free, some are open source, and some are commercial products. It's worth taking an hour or two to download one of the free products and actually see what this technology can do. Figure 1 shows a typical RSS reader, the free AmphetaDesk.

You might be wondering how this differs from the Community Pane in Visual FoxPro 8's Task Pane. While the Task Pane does offer a few select sources of FoxPro news, these are hard-coded into the program (you do have the source in HOME()\Tools\xSource) and use a proprietary interface. Instead, consider the open formats of RSS. Your reader can read all the RSS feeds in the FoxPro world, and you can follow other industry news as well as feeds about your personal interests and hobbies, from sports to quilting.

With the deluge of spam increasing on a daily basis, a growing number of companies are using RSS to publish information for dissemination to their customers instead of relying on e-mail newsletters and alerts that end up being discarded by overzealous spam filters. As a result, savvy developers now keep their RSS readers alongside their e-mail clients as a way to keep up on critical news.

Now let's publish RSS. Let's say you own the Web site example.com, and you'd like to keep your customers aware of changes happening on the Web site. Open up Notepad or your favorite editor (Visual FoxPro is my favorite) and copy the text from Listing 1, changing it as appropriate for your organization. Duplicate the ... blocks as many times as needed for your news items, and copy the file to your Web server. Let your customers and potential subscribers know the URL to retrieve with their RSS reader software and–presto!–you're an RSS publisher! This isn't as flippant a solution as it might sound at first. I have a Web site that I update once or twice a month. Editing an RSS file manually to update it may not be elegant, but it could be the most efficient use of my time and effort.

Let's talk a bit about blogging. Blogging is a form of Web publishing using RSS as its syndication mechanism. Blogging got a well-deserved bad reputation because of the millions of blogs started by pre-teens, dedicated to their cats, and abandoned after a few weeks or months. Free blogging services are available from Google, AOL, and others, and customers rightfully felt that they were worth what they paid for them–a novelty to toy with for a while and then put aside. But a blog has far more potential than that.

Blogging software is one of the most user-friendly Content Management Systems (CMS) for maintaining material on a Web page: Type your information in an editbox, hit the Post button, and your post is live, with date and time information. It can't get much easier than that! What if each of your developers could post problems as they found them, solutions as they appeared, ideas, random thoughts, requests from customers, notes from on-site visits? Error handlers could post to the blog. Projecthooks could note when files were added to the project. Source code control software could log that files were checked in. You'd get two things: lots of information and chaos. On the plus side, it's easy enough to search Web pages to see if someone else has encountered an error like yours before. On the down side, there's not a lot of organization or structure to the information unless you make it so. A blog isn't a universal solution to lack of documentation, planning, or design, but Weblogs could be one tool, used in conjunction with Wikis and other "Knowledge Management" tools, to encourage communication among developers, other staff members, and perhaps even customers.

Extending RSS to work for you

There are as many mechanisms to exchange RSS as there are applications, it seems. You can create as simple or as complex a system as your needs dictate. Here's the simplest: You run a program (or schedule it to run automatically) that generates RSS on your Web site. Your subscribers know the URL where the RSS is located, read it occasionally to determine whether it's changed, and act accordingly. It can't get much simpler than that! Why would you want a more complex system? I can envision a couple of situations.

Dynamic content–Rather than a static file on disk, you want to return a dynamic result. It can be based on a parameter passed with the request or on changing conditions of the underlying data (say, an on-hand inventory quantity). In this case, you can still consider the RSS format for the response, but the protocol to obtain it could be a request to a WestWind or ActiveFoxPro procedure, an ASP page, a Web Service call, or a Perl or Python script that dynamically generates the content and returns it.

Push vs. pull–These techniques got a bad rap in the '90s. It was the implementation that was the problem, not the underlying model. RSS in most implementations is pull (you, as an RSS consumer, pull down the RSS from the Newsweek site), but push might be a better design for some systems. For example, you might want to push your price list changes in an RSS document to your satellite offices. Obviously, an application has to be listening at the receiving end to catch the message.

ScaleIssues of scale are another reason why you might want a more complex system. For blog aggregators, it's not feasible to read every blog in existence each hour–the entire Internet would likely slow to a crawl. Rather, it's desirable to only read those blogs that have been updated. For that reason, most blogs update ("ping") a central location (like www.weblogs.com) by sending an XML message via XML-RPC or SOAP when the blog has been updated, and the news aggregators and search engines work from that list. That way, only changed blogs are read, minimizing the overhead on their Web servers and minimizing the duplicate reads done by the search engines.

Security–Another reason to add complexity to the system is if you're exchanging confidential information. Again, depending on your needs, simple solutions include encrypting your information over SSL, requiring users to log in before accessing your XML, or perhaps launching an application with programming logic to determine whether the information should be returned to a particular request based on login information, the requestor's IP address, or parameters supplied with the request. The possibilities are endless.

Summary

RSS is a technology just coming into the mainstream. RSS readers can provide you with up-to-the-minute news information, and RSS tools like news readers and blogs can improve communication among your development staff or with your customers and potential customers. RSS deserves a bit of your time to examine how it might help your business.

Sidebar: Resources

There are many sources of news readers. I found that installation, configuration, and removal of AmphetaDesk was quick, simple, and painless and recommend it for a first try at RSS.

http://blogspace.com/rss/readers

http://directory.google.com/

http://dmoz.org/

http://dir.yahoo.com/

A second category of RSS tools includes the aggregators, syndicators, search engines, and research sites. These are sites that monitor what's flying by in the RSS traffic stream, pick up on trends, and rank the highest read information.

Update: Links removed as sites are gone or no longer what they were a decade ago. -- tr, 19-Sept-2014

• http://blogstreet.com/visualneighborhood.html

www.technorati.com

• www.blogdex.com

• www.syndic8.com

• www.feedster.com

• www.daypop.com