public void Load(string url, int count) { string xml; using (WebClient client = new WebClient()) { xml = client.DownloadString(new Uri(url)); } feed.LoadXml(xml); XmlNodeList list = feed.SelectNodes("rss/channel/item"); StringBuilder builder = new StringBuilder(); int counter = 0; foreach (XmlNode node in list) { counter++; if (counter >= 5) { break; } RSSItem item = new RSSItem(); XmlNode subNode = node.SelectSingleNode("title"); item.Title = subNode != null ? subNode.InnerText : ""; subNode = node.SelectSingleNode("description"); item.Description = subNode != null ? subNode.InnerText : ""; subNode = node.SelectSingleNode("pubDate"); item.Date = subNode != null ? subNode.InnerText : ""; subNode = node.SelectSingleNode("link"); item.Link = subNode != null ? subNode.InnerText : ""; _rssItems.Add(item); } }
public void Load(string url, int count) { string xml; using (WebClient client = new WebClient()) { xml = client.DownloadString(new Uri(url)); } feed.LoadXml(xml); XmlNodeList list = feed.SelectNodes("rss/channel/item"); StringBuilder builder = new StringBuilder(); int counter = 0; foreach (XmlNode node in list) { counter++; if (counter >= 5) break; RSSItem item = new RSSItem(); XmlNode subNode = node.SelectSingleNode("title"); item.Title = subNode != null ? subNode.InnerText : ""; subNode = node.SelectSingleNode("description"); item.Description = subNode != null ? subNode.InnerText : ""; subNode = node.SelectSingleNode("pubDate"); item.Date = subNode != null ? subNode.InnerText : ""; subNode = node.SelectSingleNode("link"); item.Link = subNode != null ? subNode.InnerText : ""; _rssItems.Add(item); } }