Rssread.cs

From AdonaiMedrado.Pro.Br
Revision as of 20:52, 2 June 2009 by Adonaimedrado (Talk | contribs) (New page: <code lang="csharp"> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Net; using System.IO; namespace rssread { cl...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Net;
using System.IO;
 
namespace rssread
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = string.Empty;
 
            do
            {
                s = Console.ReadLine();
                if (!string.IsNullOrEmpty(s))
                {
                    DataSet ds = new DataSet();
                    WebClient wc = new WebClient();
                    StringReader sr = new StringReader(wc.DownloadString(s));
 
                    ds.ReadXml(sr);
 
                    Console.WriteLine(ds.Tables["channel"].Rows[0]["title"]); ;
                    for (int i = 0; i < ds.Tables["item"].Rows.Count; i++)
                    {
                        DataRow row = ds.Tables["item"].Rows[i];
                        Console.WriteLine("\t" + i + " " + row["title"]);
                        if (!string.IsNullOrEmpty((string)row["description"]))
                            Console.WriteLine("\t\t" + row["description"]);
                    }
 
                    wc.Dispose();
                    sr.Dispose();
                    ds.Dispose();
                }
            } while (!string.IsNullOrEmpty(s));
        }
    }
}