-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewrecipexml.aspx.cs
69 lines (62 loc) · 2.29 KB
/
newrecipexml.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#region XD World Recipe V 2.8
// FileName: newrecipexml.cs
// Author: Dexter Zafra
// Date Created: 5/28/2008
// Website: www.ex-designz.net
#endregion
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using XDRecipe.UI;
using System.Xml;
using System.Text;
using System.IO;
using XDRecipe.BL;
public partial class newrecipexml : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
int i = 0;
//Note: You need to change the domain name "myasp-net.com and ex-designz.net" to your site domain
Response.Clear();
Response.ContentType = "text/xml";
XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
objX.WriteStartDocument();
objX.WriteStartElement("rss");
objX.WriteAttributeString("version", "2.0");
objX.WriteStartElement("channel");
objX.WriteElementString("title", "Ex-designz.net Newest Recipe RSS Feed");
objX.WriteElementString("link", "http://www.myasp-net.com");
objX.WriteElementString("description", "Recipe database from around the world");
objX.WriteElementString("copyright", "(c) 2005, Myasp-net.com and Ex-designz.net. All rights reserved.");
objX.WriteElementString("ttl", "10");
//Get data
IDataReader dr = Blogic.ActionProcedureDataProvider.GetRSSNewestRecipe;
//loop through all record, and write XML for each item.
for (i = 0; i <= 20 - 1; i++)
{
dr.Read();
objX.WriteStartElement("item");
objX.WriteElementString("title", dr["Name"].ToString());
objX.WriteElementString("link", "http://www.ex-designz.net/recipedisplay.asp?rid=" + (int)dr["ID"]);
objX.WriteElementString("pubDate", Convert.ToDateTime(dr["Date"]).ToShortDateString());
objX.WriteEndElement();
}
dr.Close();
//End of XML file
objX.WriteEndElement();
objX.WriteEndElement();
objX.WriteEndDocument();
//Close the XmlTextWriter object
objX.Flush();
objX.Close();
Response.End();
}
}