RSS reader examples?

Hey guys!
I'm new to Xamarin but from what I've seen it seems like a pretty powerful tool. I must admit that I'm a little surprised that I haven't seen any examples of an RSS readers out there. The reason why I'm looking for one is because it seems like one of the simplest things that can be done with an app and it would showcase how to handle the network/file IO over multiple platforms.

Posts

  • JasonAwbreyJasonAwbrey USInsider, University, Developer Group Leader mod

    I used to use an RSS Reader as an example app when I do presentations on Xamarin for Cross Platform development. It's a good example of a functional app that is very simple to build.

  • TehOmbraTehOmbra CAMember

    Are any of your presentations available online?

  • muhammetsahinmuhammetsahin TRMember ✭✭

    Hi,

    This code that i used my News Reader app sample. I hope it will useful for you.

    ` public static class RssParser
    {
    static List haberDetayList;
    static Uri xmlUrl;

        // Parse the xml using XMLDocument class.
        public  static  List<NewsDetail> ParseByXMLDocument( List<NewsHeader> source)
        {
    
            int i=0;
            haberDetayList = new List<NewsDetail>();
            try
            {
                foreach (NewsHeader item in source) 
                {
                   using(var webClient = new WebClient())
                  {  
    
                        try 
                        {
                            xmlUrl = new Uri(item.Url);
                            string result = webClient.DownloadString(xmlUrl);
                            XDocument document =XDocument.Parse(result);
    
                            var temp=((from u in document.Descendants("item")
                                select new NewsDetail()
                            {
                                Id=i++,
                                NewsSource=item.NewsSource,
                                Header = item.Header,
                                Title = u.Element("title").Value,
                                Description = u.Element("description").Value,
                                Link =new Uri(u.Element("link").Value),
                                ImageUrl=u.Element("description").Value,
                                PubDate=TryDateTime(u.Element("pubDate").Value) 
    
                            }).ToList());
    
                            haberDetayList.AddRange(temp);
    
                        } 
                        catch
                        {
                            continue;
                        }
    
    
                  }
              }
            }
            catch(Exception ex) 
            {
                throw ex;
            }
    
            return haberDetayList;
    
        }
    
    }`
    

    Models are:

    ` public class NewsDetail
    {
    public int Id { get; set; }

        public string NewsSource { get; set; }
    
        public NewsSourceCategory NewsSourceType { get; set; }
    
        public string Title { get; set; }
    
        public string Header { get; set; }
    
        public string Description { get; set; }
    
        public string ImageUrl{ get; set;}
    
        public Uri Link { get; set; }
    
        public DateTime PubDate { get; set; }
    
    }`
    

    And

    ` public class NewsHeader
    {
    public string Url { get; set;}
    public string Header{ get; set;}
    public NewsSourceCategory Type{ get; set;}
    public bool IsActive { get; set; }
    public string NewsSource{ get; set;}
    }

    public static class NewsUrlConst
    {
        public const string SamanyoluHaberGundem="http://www.samanyoluhaber.com/rss.htm&id=son-dakika";
        public const string HurriyetGundem="http://rss.hurriyet.com.tr/rss.aspx?sectionId=1";
        public const string HaberturkGundem="http://www.haberturk.com/rss";
        public const string RadikalGundem="http://www.radikal.com.tr/d/rss/RssSD.xml";
        public const string ZamanGundem="http://www.zaman.com.tr/gundem.rss";
        public const string Ntv="http://www.ntvmsnbc.com/id/3032091/device/rss/rss.xml";
        public const string EnSonHaber="http://www.ensonhaber.com/rss/gundem.xml";
        public const string AnadoluAjans= "http://www.aa.com.tr/rss/ajansguncel.xml";
        public const string Fotomac= "http://www.fotomac.com.tr/rss/Anasayfa.xml";
        public const string AmkSonDakika= "http://amkspor.com/feed/";
        public const string NtvSporSonDakika= "http://www.ntvspor.net/Rss/anasayfa";
        public const string AktifHaber= "http://www.aktifhaber.com/rss/";
    }`
    
  • ShrishJainShrishJain USMember

    I am new to Xamarin and it would be great if you can you provide the entire solution with all file, which would really help to get started.

Sign In or Register to comment.