News Feed Control  
 

Really Simple Syndication (RSS) is a collection of standardized formats that are used to publish information about content that is frequently changed. A news feed is published in XML format, which contains one or more items that includes summary text, hyperlinks to source content and additional metadata that is used to describe the item. News feeds can be used for a variety of purposes, including providing updates for weblogs, news headlines, video and audio content. RSS can also be used for other purposes, such as a software updates, where new updates are listed as items in the feed.

News feeds can be accessed remotely from a web server, or locally as an XML formatted text file. The source of the feed is determined by the URI scheme that is specified. If the http or https scheme is specified, then the feed is retrieved from a web server. If the file scheme is used, the feed is considered to be local and is accessed from the disk or local network. The News Feed control provides an interface that enables you to open a feed by URL and iterate through each of the items in the feed or search for a specific feed item. The control also provides a method that can be used to parse a string that contains XML data in RSS format, where the feed may have been retrieved from other sources such as a database.

The first step your application must take is to initialize the library, which will load the required system libraries and initialize the internal data structures that are used. If the control is placed on a form, then the container automatically handles the initialization of control. If the control is created dynamically, then your application is responsible for initialization.

Initialize
Initialize the control and load the Windows Sockets control for the current process. If the control is created dynamically using a method similar to CreateObject, then the application must call this method to initialize the component before setting any properties or calling any other methods in the control.

Uninitialize
Unload the Windows Sockets library and release any resources that have been allocated for the current process. This is the last method call that the application should make prior to terminating. This is only necessary if the application has previously called the Initialize method.

News Channels

A news feed consists of a channel that contains each of the news feed items. The following properties and methods are used to access and manage the news feed channel:

Description, Title
These properties return strings that provide an overview of the news feed and a title that should be displayed for the feed. The text returned by the Title property is typically brief, while the text returned by the Description property can be more verbose, such as a paragraph that summarizes the content of the feed.

LastBuild, Published
These properties return date and time values that identify when the feed was last modified, and when it was published. While these values are often the same, they can be different and some feeds do not specify them at all. The Published property is used to specify the date when the feed was first published with the current collection of news items. If the content of a news item subsequently changes, but no new items have been added, then the publish date may remain the same but the LastBuild property would be changed to reflect when the content was modified.

Open
Open the channel by specifying a URL to the resource that contains the news. The URL can identify a remote feed that is downloaded using the HTTP or HTTPS protocols, or it can be a file on the local system or network.

Parse
Parse a string buffer that contains a news feed. This function is similar to the Open method, however it used to parse a string that contains the news feed. This method would typically be used when the feed content is obtained from a different source, such as a database or by using a different protocol. For example, the news feed could be downloaded using the FtpClient control and then passed to this function.

Close
This method closes the feed that was opened by a previous call to the Open or Parse method. When the information in a news feed is no longer needed, this method will release the resources allocated to process the feed. The current news feed will automatically be closed when an instance of the control is destroyed.

Store
This method is used to store a news feed as a file on the local system. This is typically used to cache the contents of a news feed or to track the changes made to the feed over time. It is recommended that the application periodically check the publication date of the feed to ensure that they have current version.

News Items

News feed items are identified by a numeric value called the item ID. This is used with other functions to return information about a specific news item. The first item in a news feed has an ID of one and it increments for each additional item in the feed.

ItemCount
This property will return the number of news items in the feed. The first item in the feed has a value of one, and it increments for each additional news item. This property can be used in conjunction with the GetItem method to enumerate all of the news items in the feed.

ItemTitle
This property will return a string which specifies a title for the news item. If no title has been specified, this property will return an empty string. Although it is not required for a news item to have a title, a feed that conforms to the standard must have either a title or a description of the item, which is returned by the ItemText property

ItemText
This property will return a string that contains a summary of the current news item. This may property may return either plain text or HTML formatted text. If no text has been specified for the current item, this property will return an empty string. Although it is not required for a news item to have a description, a feed that conforms to the standard must have either a description of the item or a title, which is returned by the ItemTitle property.

ItemLink
This property will return a string which specifies a URL that provides additional information about a news item. If the news item summarizes the contents of an article, this property typically provides a link to the complete article. If a link is not specified for the news item, this property will return an empty string.

ItemGuid
This property will return a string which uniquely identifies the current news item. If this property is defined, it is guaranteed to be a unique, persistent value. It is important to note that this string does not have to be a standard GUID reference number, it can be any unique string. If there is no unique identifier associated with the current item, this property will return an empty string.

GetItem
This method is used to return information about a specific news item based on the item ID. This becomes the current news item, and it updates the item-related properties such as ItemTitle and ItemText.

FindItem
This method is used to search the feed channel for a specific item, based either on its GUID, title, link or publication date. When searching for a specific item, only searches by GUID are guaranteed to return a unique news item. However, since not all news feeds may provide GUIDs for their news items, additional search criteria can be used when necessary. If this method succeeds, the item that matched the search criteria becomes the current news item.