CNewsFeed::ValidateFeed Method  
 
INT ValidateFeed(
  LPCTSTR lpszFeedUrl,  
  UINT nTimeout,  
  DWORD dwOptions,  
  LPSYSTEMTIME lpstModified  
);
INT ValidateFeed(
  LPCTSTR lpszFeedUrl,  
  LPSYSTEMTIME lpstModified  
);
INT ValidateFeed(
  LPCTSTR lpszFeedUrl  
);

The RssValidateFeed method is used to validate a news feed, returning the number of items in the feed and the date it was last modified.

Parameters

lpszFeedUrl
A null-terminated string 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 specified. To access a file on the local system or network share, a file name or file URL may be specified.
nTimeout
The number of seconds that the client will wait for a response from the server before failing the current operation. This parameter is ignored if the lpszFeedUrl parameter specifies a local file name or URL.
dwOptions
An unsigned integer that specifies one or more options. This parameter is reserved for future use an should always have a value of zero.
lpstModified
A pointer to a SYSTEMTIME structure which will specify the date that the feed was last modified when the method returns. If the parameter is NULL, it is ignored and no information is returned.

Return Value

If the method succeeds, the return value is the number of items in the news feed channel. If the method fails, the return value is RSS_ERROR. To get extended error information, call RssGetLastError.

Remarks

The RssValidateFeed method can be used to check that a news feed exists and is properly formatted. If the contents of the feed are valid, the method will return the number of items in the feed and the date that it was last modified. This can be useful for applications that want to periodically check a news feed and determine if the contents have changed.

The SYSTEMTIME structure that is populated by the method specifies the date when the feed was last modified. The method first checks the value of the lastBuildDate property of the feed channel. If that property is not defined, then it will use the value of the pubDate property. If neither are defined, then the structure members will have a value of zero.

The validation process imposes strict checks on the structure of the news feed and requires that it conform to the RSS specification. For example, the feed must have a title, link and description. Each item in the feed must have either a title or description, and the hyperlinks specified in the feed must be valid. If the feed XML is malformed, or a required property of the feed is invalid or missing, this method will fail.

If a news feed cannot be validated, it still may be possible to open the feed using the OpenFeed method. By default, relaxed rules are used when parsing the contents of the feed and it does not check to ensure all required properties are defined and have valid values.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csrssv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also