/*
. Net/C #: Use reflection to compile a reader for general rss 2.0
I recently wrote a Simple Rss Reader.
There are two types of off-the-shelf code found on the Internet:
1. The code is simple, but not general enough (for example, some special rss reader on this site)
2. The code is complex, but there is not enough time to digest it (for example, rssbandit)
Start by yourself:
We have all the basic attributes of rss!
But some special non-General attributes, such:
Slash: comments
Wfw: comment
Wfw: commentRss
Trackbackping
Not necessarily exist! What should I do ???
I thought of Reflection and proposed the following solutions:
1. Class RssHeader is used to indicate the Rss header information
You can add a new attribute to it in the following way:
The member variable Fieild is named rss. The attribute name corresponding to the XML source is prefixed with an underscore. The XML Attribute name contains ":" to filter it out!
For example, <dc: language> zh-CHS </dc: language>
Picture it:
Private string _ dclanguage
Public string DcLanguage
{
Get
{
Return this. _ dclanguage;
}
}
2. Class RssItem is used to represent the Rss Item
The rule for adding new attributes is the same as RssHeader!
3. Retrieve the rss XML source and recursively traverse the node (class SimpleRssReader)
According to the actual rss attributes, through reflection, "construct and instantiate" RssHeader and RssItem!
Please refer to the Travel method of class SimpleRssReader carefully!
4. Database (this article uses Micrshaoft Data Access Application Block 3.1)
Table:
Channels (main table)
ChannelsDetails (detail table)
The field name and its data type strictly follow the attribute name corresponding to the rss XML source. The XML Attribute name contains ":" to filter it out!
Stored Procedure:
SP_AddChannel
SP_AddChannelsDetails
The parameter name and its data type are strictly in accordance with the attribute name corresponding to the rss XML source. The XML Attribute name contains ":" to filter it out!