Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Code:
Selected Language:
Show Linenumbers:
Short link for Twitter:
HTML:

HTML view:

Copy Source | Copy HTML
  1. //говорим, что ответом есть XML/RSS
  2. Response.ContentType = "application/rss+xml";
  3. //вытаскиваем из ьазы данные
  4. using (MySQL db = new MySQL())
  5. {
  6.     DataSet ds = db.GetData("get_rss");
  7.     if (ds != null && ds.Tables[0].Rows.Count > 0)
  8.     {
  9.         RssDocument rss = new RssDocument()
  10.         {
  11.             Version = "2.0",
  12.             Channel = new RssChannel()
  13.             {
  14.                 LastBuildDate = DateTime.Now.ToString(),
  15.                 Language = "ru-RU",
  16.                 WebMaster = "topbot@ya.ru",
  17.             }
  18.         };
  19.         rss.Channel.Title = "blabla"
  20.         rss.Channel.Link = ds.Tables[0].Rows[0]["linkto"].ToString();
  21.         rss.Channel.Items = new List<RssItem>(0);
  22.         foreach (DataRow dr in ds.Tables[0].Rows)
  23.         {
  24.             RssItem ritem = new RssItem()
  25.             {
  26.                 PubDate = ((DateTime)dr["when"]).ToString("s"),
  27.                 Description = dr["text"].ToString()
  28.             };
  29.             rss.Channel.Items.Add(ritem);
  30.         }
  31.         Response.Write(rss.ToXml(DocumentType.Rss));
  32.     }
  33.     else
  34.     {
  35.         Response.ContentType = "application/rss+xml";
  36.     }
  37.  
  38. }




Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2018