using (XmlTextWriter Writer = new XmlTextWriter(HttpContext.Current.Server.MapPath("~/Rss/HotProductList.xml"), System.Text.Encoding.UTF8))
        {
            Writer.Formatting = Formatting.Indented;
            Writer.WriteStartDocument();
            Writer.WriteStartElement("rss");
            Writer.WriteAttributeString("version", "2.0");
            Writer.WriteStartElement("channel");
            Writer.WriteElementString("title", "最新产品");
            Writer.WriteElementString("link",  "http://shop.myweb08.cn/ProductsList.aspx?type=new");
            Writer.WriteElementString("description", "最新产品http://shop.myweb08.cn/ProductsList.aspx?type=new");

            DataTable dt = Product.GetProduct();//获取产品DataTable
            foreach (DataRow row in dt.Rows)
            {
                Writer.WriteStartElement("item");
                Writer.WriteElementString("title", row["ProductName"].ToString());//产品名
                Writer.WriteElementString("link",  "http://shop.myweb08.cn/prodct/" + row["ProductName"].ToString() + ".html");//产品链接
                Writer.WriteElementString("description", row["Description"].ToString());//产品描述
                Writer.WriteElementString("author", "http://shop.myweb08.cn/");
                Writer.WriteElementString("pubDate", row["AddTime"].ToString());//更新时间
                Writer.WriteEndElement();
            }
            Writer.WriteEndElement(); 
            Writer.WriteEndElement();
            Writer.WriteEndDocument();
        }

 

 (已)

相关文章:

  • 2021-09-09
  • 2021-05-01
  • 2022-12-23
  • 2021-11-13
  • 2021-10-22
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-05
  • 2021-12-11
  • 2022-02-08
  • 2022-12-23
  • 2021-11-20
相关资源
相似解决方案