using System; using System.Collections.Generic; using System.Xml; using System.ServiceModel.Syndication; namespace LJUpper { public static class RSS { public struct RssItem { public string Title { get; set; } public string Text { get; set; } } public static List<RssItem> GetRSS(string _feedUri) { SyndicationFeed syndicationFeed; List<RssItem> resList = new List<RssItem>(); try { using (XmlReader reader = XmlReader.Create(new Uri(_feedUri).AbsoluteUri)) syndicationFeed = SyndicationFeed.Load(reader); string _title = ""; string _text = ""; foreach (SyndicationItem t in syndicationFeed.Items) { if (t.Title == null) _title += t.Title.Text; if (t.Content == null) _text += t.Summary.Text; else _text += (t.Content as TextSyndicationContent).Text; resList.Add(new RssItem() { Title = t.Title.Text, Text = _text }); } } catch { return null; } return resList; } } }
c# read rss
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.