WEB 2.0 is a new generation of Internet models represented by BLOG, WIKE, TAG, RSS and other technologies, and RSS seems to be too hot than the names such as blog. However, open the web is still a hidden icon, which is overwhelmed by RSS, XML. Open the page Mathon browser is also a strong prompt has a new RSS connection, one item in the previous paragraph
Types need to write a class that generates RSS information below, as follows:
1using system.xml; 3using system.collections; 4using system.globalization; 5using system.Web; 6 7NameSpace BLRL 8 {9 ///
57 public static XmlDocument AddRssPreamble (XmlDocument xmlDocument) 58 {59 // declaration creates version 1.0 available xml 60 XmlDeclaration xmlDeclaration = xmlDocument.CreateXmlDeclaration ( "1.0", "utf-8", null); 61 xmlDocument.InsertBefore (xmlDeclaration, xmlDocument. DocumentElement); 62 63 XmlElement rssElement = xmlDocument.CreateElement ( "rss"); 64 65 XmlAttribute rssVersionAttribute = xmlDocument.CreateAttribute ( "version"); 66 rssVersionAttribute.InnerText = "2.0"; 67 rssElement.Attributes.Append (rssVersionAttribute); 68 xmlDocument.AppendChild (rssElement); 69 70 71 XmlAttribute dublicCoreNamespaceUriAttribute = xmlDocument.CreateAttribute ( "xmlns: dc"); 72 dublicCoreNamespaceUriAttribute.InnerText = dublinCoreNamespaceUri; 73 rssElement.Attributes.Append (dublicCoreNamespaceUriAttribute); 74 75 XmlAttribute slashNamespaceUriAttribute = xmlDocument.CreateAt tribute ( "xmlns: slash"); 76 slashNamespaceUriAttribute.InnerText = slashNamespaceUri; 77 rssElement.Attributes.Append (slashNamespaceUriAttribute); 78 79 XmlAttribute syndicationNamespaceUriAttribute = xmlDocument.CreateAttribute ( "xmlns: sy"); 80 syndicationNamespaceUriAttribute.InnerText = syndicationNamespaceUri; 81 rsselement.attributes.Append (SyndicationNamespaceuriattribute); 82 83 84 returnction xmldocument; 85} 86 87 ///
/ Param> 91 /// param> 92 ///
123 webMasterElement.InnerText = channel.webMaster; 124 channelElement.AppendChild (webMasterElement); 125126 return xmlDocument; 127} 128129130 // Add RssImage131 private static XmlDocument AddRssImage (XmlDocument xmlDocument, RssImage img) 132 {133 XmlElement imgElement = xmlDocument.CreateElement ( " image "); 134 XmlNode channelElement = xmlDocument.SelectSingleNode (" rss / channel "); 135136 // Create a header 137 XmlElement imageTitleElement = xmlDocument.CreateElement (" title "); 138 imageTitleElement.InnerText = img.title; 139 imgElement.AppendChild (imageTitleElement); 140141 // Create address 142 XmlElement imageUrlElement = xmlDocument.CreateElement ( "url"); 143 imageUrlElement.InnerText = img.url; 144 imgElement.AppendChild (imageUrlElement); 145146 // Create a height 147 XmlElement imageHeightElement = xmlDocument. CreateElement ("Height"); 148 imageHeightElement.InnerText = img.height.ToString (); 149 imgElement.AppendChild (imageHeightElement); 150151 // Create length 152 XmlElement imageWidthElement = xmlDocument.CreateElement ( "width"); 153 imageWidthElement.InnerText = img.width.ToString () ; 154 imgElement.AppendChild (imageWidthElement); 155156 // add images to a node inside the channel node 157 channelElement.AppendChild (imgElement); 158 return xmlDocument; 159 160} 161162163 ///
167 /// param> 168 ///
// Create Type 195 196 197 198 XmlElement itemcatalogElement = xmlDocument.CreateElement ( "catalog"); 199 itemcatalogElement.InnerText = item.catalog; 200 itemElement.AppendChild (itemcatalogElement); 201202 // RssItem added to the node inside the channel 203 channelElement.AppendChild ( ItemElement; 204205 Return XMLDocument; 206} 207} 208} Depending on the specific needs, the data can be read in the list, and then traverse the list, call the above method, generate an XML string.
This string is RS to use the XML string. You can also enter the ASPX file, then use
<
LINK
Type
= "Application / RSS XML"
Rel
= "alternate"
HREF
= "rssfeed.aspx"
>
Call the RSS file, toilet and other software will automatically prompt to have RRS information.
Title = "Cool Network Community" href = "rssfeed.aspx" type = "Application / RSS XML" Rel = "alternate" />
http://jillzhang.cnblogs.com/archive/2006/06/11/423086.html title = "Cool Network Community" href = "rssfeed.aspx" type = "Application / RSS XML" Rel = "alternate" / > title = "Cool Network Community" href = "rssfeed.aspx" type = "Application / RSS XML" Rel = "Alternate" /> Title = "Cool Network Community" HREF = "rssfeed.aspx" type = "Application / RSS XML "rel =" alternate "/> Title =" Cool Network Community "href =" rssfeed.aspx "type =" Application / RSS XML "Rel =" Alternate "/> Title =" Cool Network Community "href = "rssfeed.aspx" type = "Application / RSS XML" rel = "alternate" /> title = "cool network community" href = "rssfeed.aspx" type = "Application / RSS XML" Rel = "alternate" / >