Click here to Skip to main content
15,846,342 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone,
now i am devopling a weppage, it contains some rss feed from database,i can read data from database, and feed into xml file. now i have a problem to display a xml in the form. when i try run my form , it will be downloaded and apllication is goes to stop.. where i can mistake, i can't find it.

here is my coding :
protected void Page_Load(object sender, EventArgs e)
   {
       Response.Clear();
       Response.ContentType = "application/rss.xml";
       XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
       objX.WriteStartDocument();
       objX.WriteStartElement("rss");
       objX.WriteAttributeString("version", "2.0");
       objX.WriteStartElement("channel");

       SqlCommand cmd = new SqlCommand("Select  * From rss_feed ORDER BY ID DESC", conn);
       cmd.Connection.Open();
       SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
       {
           objX.WriteStartElement("item");
           objX.WriteElementString("title", dr["Title"].ToString());
           objX.WriteElementString("Category", dr["Category"].ToString());
           objX.WriteElementString("DateTimeAdded", dr["DateTimeAdded"].ToString());
           objX.WriteElementString("Article", dr["Article"].ToString());
           objX.WriteEndElement();
       }

       objX.WriteEndElement();
       objX.WriteEndElement();
       objX.WriteEndDocument();
       objX.Flush();
       objX.Close();
       Response.End();

here i am got nothing display in my browser. one file downloading from after execution,
and one thing i need some examples(website link) about rss feed.find where i am mistake here please.(i am placed my file into folder (feed/rss.aspx).and palce a code in my page load event).
Posted

1 solution

Refer to question answered by me

Query about RSS FEED[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900