RSS stands for Really Simple Syndication.
Its allows you to syndicate your site content.
RSS is written in XML.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
public partial class rss : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = "Data Source=HP11-PC\\SQLEXPRESS;Initial Catalog=cp;Integrated Security=True";
DataTable dt = new DataTable();
SqlConnection conn = new SqlConnection(connectionString);
using (conn)
{
SqlDataAdapter ad = new SqlDataAdapter("SELECT top 100 * from tblbuilder", conn);
ad.Fill(dt);
}
Response.Clear();
Response.ContentType = "text/xml";
XmlTextWriter TextWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
TextWriter.WriteStartDocument();
TextWriter.WriteStartElement("rss");
TextWriter.WriteAttributeString("version", "2.0");
TextWriter.WriteStartElement("channel");
TextWriter.WriteElementString("title", "C#.NET,ASP.NET Samples and Tutorials");
TextWriter.WriteElementString("link", "http://ask-dotnet.blogspot.in/");
TextWriter.WriteElementString("description", "Free ASP.NET articles,C#.NET,ASP.NET tutorials and Examples,Ajax,SQL Server,Javascript,XML code examples -- by Chandra prakash");
TextWriter.WriteElementString("copyright", "Copyright 2009 - 2014 aspdontnet.blogspot.com. All rights reserved.");
foreach (DataRow feed in dt.Rows)
{
TextWriter.WriteStartElement("item");
TextWriter.WriteElementString("name", feed["buildername"].ToString());
TextWriter.WriteElementString("link", "http://ask-dotnet.blogspot.in//Property-" + feed["buildername"].ToString());
TextWriter.WriteElementString("description", feed["description"].ToString());
TextWriter.WriteEndElement();
}
TextWriter.WriteEndElement();
TextWriter.WriteEndElement();
TextWriter.WriteEndDocument();
TextWriter.Flush();
TextWriter.Close();
Response.End();
}
}
OUTPUT :
<rss version="2.0">
</rss>
No comments :
Post a Comment