|
Open the specified news feed and select the first news item.
Syntax
object.Parse( FeedXml, [Options] )
Parameters
- FeedXml
- A string value which contains the contents of the news feed to
be parsed.
- 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 |
Description |
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. |
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 string contains a valid RSS
feed and the contents were successfully parsed. 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
The Parse method is an alternative to the Open
method, enabling the application to process a news feed from
alternative sources such as a database or compressed file. It is
important to note that the string which contains the news feed XML
must be properly formatted and conform to the RSS standard
specification.
Example
The following example opens a local file that contains a news
feed, stores the contents in a string variable and parses the
contents. A ListBox control is populated with the title of
each news item in the feed. Note that this example was written to
demonstrate the use of the Parse method, however the
Open method can also be used to open a local file and requires
less code.
Dim hFile As Long
Dim strFileName As String
Dim strFeedXml As String
Dim nIndex As Long
Dim nError As Long
strFileName = "newsfeed.xml"
hFile = FreeFile()
Open strFileName For Input As #hFile
strFeedXml = Input(LOF(hFile), #hFile)
Close #hFile
nError = NewsFeed1.Parse(strFeedXml)
If nError > 0 Then
MsgBox NewsFeed1.LastErrorString, vbExclamation
Exit Sub
End If
ListBox1.Clear
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, Store Method
|
|