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", "latest product ");
Writer. WriteElementString ("link", "http://shop.myweb08.cn/ProductsList.aspx? Type = new ");
Writer. WriteElementString ("description", "latest product http://shop.myweb08.cn/ProductsList.aspx? Type = new ");
DataTable dt = Product. GetProduct (); // get the Product DataTable
Foreach (DataRow row in dt. Rows)
{
Writer. WriteStartElement ("item ");
Writer. WriteElementString ("title", row ["ProductName"]. ToString (); // Product Name
Writer. WriteElementString ("link", "http://shop.myweb08.cn/prodct/" + row ["ProductName"]. ToString () + ". html"); // product link
Writer. WriteElementString ("description", row ["Description"]. ToString (); // product description
Writer. WriteElementString ("author", "http://shop.myweb08.cn /");
Writer. WriteElementString ("pubDate", row ["AddTime"]. ToString (); // Update Time
Writer. WriteEndElement ();
}
Writer. WriteEndElement ();
Writer. WriteEndElement ();
Writer. WriteEndDocument ();
}
(Already)