using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xml.Linq; using System.IO; using System.Xml; namespace MehmetDuran { public class RssItem { public string Baslik { set; get; } public string Tanim { set; get; } public DateTime Tarih { set; get; } public string Link { set; get; } } public class Rss { public string Baslik { set; get; } public string Tanim { set; get; } public string Link { set; get; } public string Author { set; get; } public List Items { set; get; } public DateTime GuncellenenTarih { set; get; } public string Resim { get; set; } public Rss(string RssBaslik, string RssTanim, string RssLink, string RssAuthor, List RssItems, DateTime RssGuncellenenTarih, string RssResim) { this.Baslik = RssBaslik; this.Tanim = RssTanim; this.Link = RssLink; this.Author = RssAuthor; this.Items = RssItems; this.GuncellenenTarih = RssGuncellenenTarih; this.Resim = RssResim; } public string RssSonuc() { XDocument doc = new XDocument ( new XDeclaration("1.0", "UTF-8", ""), new XElement ( "rss", new XAttribute("version", "2.0"), new XElement ( "channel", new XElement("title", Baslik), new XElement("link", Link), new XElement("description", Tanim), new XElement("image", new XElement("url", Resim)) ) ) ); foreach (RssItem item in Items) { XElement i = new XElement ( "item", new XElement("title", item.Baslik), new XElement("link", item.Link), new XElement("pubDate", item.Tarih), new XElement("description", item.Tanim) ); doc.Element("rss").Element("channel").Add(i); } MemoryStream ms = new MemoryStream(); XmlWriter xw = XmlWriter.Create(ms); doc.Save(xw); xw.Close(); return new System.Text.UTF8Encoding().GetString(ms.ToArray()); } } }