In the Web 2.0 era, it is difficult for us to discover RSS on a Web website. We can use RSS readers to subscribe to updates and news from specific websites. With the popularity of Vista, many people will also subscribe to the Windows Sidebar on the desktop so that updates on the website can be seen every time they start up. RSS is composed of several special XML tags. I 'd like to know the meaning of these tags to define my RSS. In this article, we will see several important RSS labels. When we understand the RSS labels, we can use
Xmltextwriter
Object To combine our own RSS files.
First of all we need to know is the XML format, is a pair of closed labels, the top of a <XML/> MARK contains Character Set and version, such as the general use of UTF-8, Version 1.0. Of course, the RSS document label must be RSS. Since RSS has multiple versions to add versions, you can declare some namespaces (?...). (Note: XML is case sensitive)
1 <? XML version = "1.0" encoding = "UTF-8" ?>
2 < RSS Version = "2.0" >
3 < Channel >
4 < Title > </ Title >
5 < Link > </ Link >
6 < Description > </ Description >
7
8
9 < Item >
10
11 </ Item >
12 </ Channel >
13 </ RSS >
The above is the basic format of rss2.0, listing all the required tags, of course, there are many optional tags. We can use the followingCodeTo complete our RSS, of course, we usually retrieve the matching records from the database and output the subscribed content through the following methods.
1 // Clear output Cache
2 Response. Clear ();
3 // Set output type
4 Response. contenttype = " Text/XML " ;
5
6 // Initialize xmltextwriter class
7 Xmltextwriter writer = New Xmltextwriter (response. outputstream, encoding. utf8 );
8
9 // Write <? XML version = "1.0" encoding = "UTF-8"?>
10 Writer. writestartdocument ();
11
12 // Write <RSS version = "2.0">
13 Writer. writestartelement ( " RSS " );
14 Writer. writeattributestring ( " Version " , " 2.0 " );
15
16 // Write <channel>
17 Writer. writestartelement ( " Channel " );
18
19 // Write <title/> <link/> <description/> required and add copyright to the file <copyright/>
20 Writer. writeelementstring ( " Title " , " . Net flipper " );
21 Writer. writeelementstring ( " Link " , " Http://www.mshelper.cn/ " );
22 Writer. writeelementstring ( " Description " , " My blog " );
23 Writer. writeelementstring ( " Copyright " , " Copyright " + Datetime. Now. year. tostring () + " . All rights reserved. " );
24
25 // Loop output item.
26 While (Statement)
27 {
28 Writer. writestartelement ( " Item " );
29 Writer. writeelementstring ( " Title " , " RSS label " );
30 Writer. writeelementstring ( " Description " , " Introduction " );
31 Writer. writeelementstring ( " Link " , " Http://www.mshelper.cn/id=1 " );
32 Writer. writeendelement ();
33 }
34 Dr. Close ();
35
36 // Close tags
37 Writer. writeendelement ();
38 Writer. writeendelement ();
39 Writer. writeenddocument ();
40 // Release cache and output.
41 Writer. Flush ();
42 Writer. Close ();
The above only lists some of the class labels. There are actually many useful labels, but the above labels are enough for a common content. If you want more tags, you can find them in rss2.0 specificaion (rss2.0 at Harvard Law. A lot of abstract things, in fact, you just need to approach him, to warm him slowly will be melted by you :)