'ClassId''].ToString();
//string author=row[''author''].ToString();
strCode.Append(''<item>'');
strCode.Append(''<title>''+title+''</title>'');
strCode.Append(''<link>http://''+Request.ServerVariables[''SERVER_NAME'']+''/NewsShow.aspx?ID=''+Id+''</link>'');
strCode.Append(''<subject>''+description+''</subject>'');
strCode.Append(''<description><![CDATA[''+description+'']]></description>'');
strCode.Append(''<PubDate>''+pubdate+''</PubDate>'');
strCode.Append(''<category>''+ClassId+''</category>'');
strCode.Append(''</item>'');
}
strCode.Append(''</channel>'');
strCode.Append(''</rss>'');
return strCode.ToString();
}
(3) XmlTextWriter实现方式2;Rss.aspx.cs
string xmlDoc=''rss.xml'';
private void Page_Load(object sender, System.EventArgs e)
{
xmlDoc=Server.MapPath(''.'')+xmlDoc;
GetRSS2();
XmlDocument doc= new XmlDocument();
doc.Load(xmlDoc);
Response.ContentType = ''text/xml'';
doc.Save(Response.Output);
}
/// <summary>
/// 取得聚合文章
/// </summary>
/// <returns></returns>
public void GetRSS2()
{
News t=new News();
DataSet ds=t.GetListByClass(1);
XmlTextWriter writer = new XmlTextWriter(xmlDoc,Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.WriteStartDocument(true);
writer.WriteComment(''RSS页的实现'');
writer.WriteStartElement(''rss'');
writer.WriteAttributeString(''version'',''2.0'');
writer.WriteStartElement(''channel'');
writer.WriteStartElement(''title'');
writer.WriteString(''李天平RSSDemo'');
writer.WriteEndElement();
writer.WriteStartElement(''link'');
writer.WriteString(''http://''+Request.ServerVariables[''SERVER_NAME'']);
writer.Wri |