using System; using System.Collections; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.ServiceModel.Syndication; //using System.ServiceModel.Web; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Text; using System.Xml; using System.Xml.Linq; public partial class Default2 : System.Web.UI.Page { public override void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; string sTitle = "Minu uudised"; string sSiteUrl = "http://localhost:59198/RSS"; string sDescription = "The site is the coolest bla bla and this rss feed is the best!"; string sTTL = "1"; XmlTextWriter objX = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8); objX.WriteStartDocument(); objX.WriteStartElement("rss"); objX.WriteAttributeString("version","2.0"); objX.WriteStartElement("channel"); objX.WriteElementString("title", sTitle); objX.WriteElementString("link",sSiteUrl); objX.WriteElementString("description",sDescription); objX.WriteElementString("copyright","(c) 2008, Erki Savisaar. All rights reserved."); objX.WriteElementString("ttl",sTTL); SqlConnection objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString); objConnection.Open(); string sql = "SELECT kood, pealkiri, kirjeldus, kuup FROM uudised ORDER BY kuup DESC"; SqlCommand objCommand = new SqlCommand(sql, objConnection); SqlDataReader objReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection); while (objReader.Read()) { objX.WriteStartElement("item"); objX.WriteElementString("title",objReader.GetString(1)); objX.WriteElementString("description",objReader.GetString(2)); objX.WriteElementString("link",String.Format("http://veebistuudium.eneta.ee/ErkiSavisaar/RSS/NaitaUudist.aspx?id={0}", objReader.GetInt32(0))); objX.WriteElementString("pubDate", objReader.GetDateTime(3).ToString("R")); objX.WriteEndElement(); } objReader.Close(); objX.WriteEndElement(); objX.WriteEndElement(); objX.WriteEndDocument(); objX.Flush(); objX.Close(); } }