Open Method  
 

Open the specified news feed and select the first news item.

Syntax

object.Open( FeedUrl, [Timeout], [Options] )

Parameters

FeedUrl
A string value which specifies the URL for the news feed. To access a news feed on a web server, a standard http or https URL may be used. To access a file on the local system or network share, a file name or file URL may be specified.
Timeout
The number of seconds that the client will wait for a response before failing the operation.This parameter is ignored if the FeedUrl parameter specifies a local file name or URL.
Options
An optional numeric parameter that specifies one or more options when opening the news feed. This parameter is constructed by using a bitwise operator with any of the following values:
Value Constant Description
0 rssOptionNone No additional options are specified and the news feed is processed using relaxed rules when checking the validity of the feed. The control will attempt to automatically compensate for a feed that is malformed or does not strictly conform to the RSS standard. This is the default value if the Options parameter is omitted.
1 rssOptionStrict The news feed content should be processed using strict rules to ensure that the feed meets the appropriate RSS standard specification and all feed property values are case-sensitive. By default, relaxed rules are used which allows the application to open a feed that may not strictly conform to the standard specification.

Return Value

A value of zero is returned if the news feed was opened successfully. Otherwise, a non-zero error code is returned which indicates the cause of the failure. If the method fails, the value of the LastError property can be used to determine cause of the failure.

Remarks

A news feed may be local or remote, depending on the URL that is specified. If a local file name or file URL is specified for the feed, then it is opened locally and no network access is required. If an http or https URL is specified, then the Open method will attempt to download the feed from the server and store it temporarily on the local system. Accessing a remote feed requires that the application has permission to establish a connection with the server and will cause the application to block until the feed has been downloaded, the operation times out or an error occurs.

Although the Open method will meet the needs of most applications, if you require more complex functionality such as retrieving the feed asynchronously in the background or event notifications for large transfers, you can use the SocketTools Hypertext Transfer Protocol control to download the news feed and then use the Parse method to parse the contents.

Example

The following example accesses a remote feed and enumerates each news item, populating the contents of a ListBox control with its title.

Dim strFeed As String
Dim nIndex As Long
Dim nError As Long
    
strFeed = "http://sockettools.com/rss/news.xml"
ListBox1.Clear
    
nError = NewsFeed1.Open(strFeed)
If nError > 0 Then
    MsgBox NewsFeed1.LastErrorString, vbExclamation
    Exit Sub
End If
    
Label1.Caption = NewsFeed1.ItemCount & " news items, published on " & NewsFeed1.Published
    
For nIndex = 1 To NewsFeed1.ItemCount
    nError = NewsFeed1.GetItem(nIndex)
    If nError > 0 Then
        MsgBox NewsFeed1.LastErrorString, vbExclamation
        Exit For
    End If
    ListBox1.AddItem NewsFeed1.ItemTitle
Next

See Also

Close Method, GetItem Method, Open Method, Parse Method, Store Method