advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the code for this article
Partners & Affiliates
advertisement
advertisement
Average Rating: 5/5 | Rate this item | 5 users have rated this item.
 Print Print
 
Learn to Consume RSS Using DevX's New Content Feeds
Now it's easier than ever to find out what's new at DevX. This article will show you two simple ways of pulling links to new DevX content into your own sites using an XML standard called RSS . Get started with one of our feeds today, or use these techniques to pull in feeds from all over the Net. 

advertisement
SS (Really Simple Syndication) feeds are an easy way for organizations to distribute content. At the most basic level, an RSS feed, or channel, is an XML document containing a list of titles, descriptions, and links to content. Any client that can parse XML can read and format the content to display the titles, descriptions, and links in a custom context, such as within a <div> tag on a Web page or on a Windows form.


To use an RSS feed, you need to:

Create the context.
Decide what you want to do with the feed and how you want it to look.

Retrieve the XML feed.
All you need is the URL for the feed location. Then you make a standard HTTP GET request for the XML data. You can treat the result as a file, writing it to local storage, or as transient in-memory data.

Parse and format the results.
To display the contents, you need to parse the XML document, extracting and formatting the information you want to display. The simplest way to do that is to use an XSLT stylesheet to control the display characteristics.

Editor's Note: If you're interested in using the DevX content feeds either individually or on a Web site, visit our RSS FAQ page.

RSS 2.0 Document Structure
Figure 1. Viewing the XML: In the sample application, you can hit the "Show RSS Document" button to invoke the getXMLFeed method, which displays the raw XML.
RSS has gone through three versions since its inception. DevX's feeds adhere to the latest specification, RSS 2.0.

Let's begin by running through the basic structure of a feed. An RSS 2.0 document must begin with the standard XML declaration containing version and encoding attributes.


<?xml version="1.0" encoding="ISO-8859-1" ?>

The next tag is an <rss> element containing a single <channel> child element. The <channel> element must contain title, link, and description elements. These typically contain the title of the feed source organization, a link to that organization, and a description of the feed contents. For example, DevX's <channel> element looks like this:


<channel>
    <title>DevX: Latest Published Articles</title>
    <link>http://www.devx.com</link>
    <description>Latest DevX Content</description>
    ... <!-- more channel information here -->

In addition to the three required elements, the <channel> element may contain a number of optional elements;. DevX uses these additional elements:


    <language>en-us</language>
    <copyright>Copyright 2002 DevX</copyright>
    <docs>http://backend.userland.com/rss</docs>
    <lastBuildDate>Wed, 18 Jun 2003 
        23:30:51 PST</lastBuildDate>
    <image>
       <title>DevX</title>    
       <url>
        http://services.devx.com/outgoing/devxwire.gif
       </url>
       <link>http://www.DevX.com</link>
    </image>

The optional elements <language>, <copyright>, and <image> are mostly self-explanatory. The <copyright> element tells you the source of the feed while the <image> element is used in our case to display the DevX logo.

The <docs> element is documentation for the RSS version and usually links to the Radio UserLand RSS page as shown. The <lastBuildDate> element is particularly important for automation purposes. Some organizations, such as those with stock market feeds, update their RSS feeds often; others, such as DevX, update the feeds on a daily basis, or only when information changes. If you're caching feeds information locally, you only need to update the cache when the value of the <lastBuildDate> element changes.

The <channel> element also contains a list of <item> elements. These are the individual pieces of content. All <item> child elements are optional, but each <item> must contain, at minimum, a <title> or a <description> element. In practice, most <item> elements contain a title, a link, and a description. Again, the RSS 2.0 specification lists optional <item> elements. DevX uses the following <item> structure.


<item>
  <title>Title here</title>        
  <description>Description</description>
  <link>URL</link>
  <author>Author(s) names</author>
  <pubDate>Thu, 12 Jun 2003 13:23:27 PST</pubDate>
</item>

Obtaining a DevX RSS Feed with .NET
Obtaining the content of a DevX RSS feed (or performing any HTTP GET request) with .NET is straightforward. You simply add a reference to the System.Net namespace to your class or module.


Imports System.Net

After doing that, you can use the WebClient object in the System.Net namespace to make requests to a URL and retrieve the results. The following getXMLFeed method uses a WebClient to request the XML data. The method might just as easily be called "DoHTMLGetRequest," because it isn't specific to XML nor to RSS feeds—it just makes a GET request and returns the result.


   Public Function getXMLFeed( _
      ByVal URL As String) As String
      Dim wc As New WebClient
      Dim b() As Byte
      Dim sXML As String = String.Empty
      b = wc.DownloadData(URL)
      sXML = System.Text.Encoding.ASCII.GetString(b)
      Return sXML
   End Function

The sample application in this article (and in the downloadable source code, left) obtains the RSS documents from DevX using the getXMLFeed method.

  Next Page: Transforming the RSS Feed to HTML


Page 1: IntroductionPage 3: Perform the XSLT Transform
Page 2: Transforming the RSS Feed to HTML 
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES