I have an RSS feed which I am currently displaying 2 items, what I am wanting is for every time the page is reloaded that a different 2 items are displayed. The code I currently have is
//BBC UK
string RssFeedUrl = "http://ift.tt/1Rjha6i";
List<Feeds> feeds = new List<Feeds>();
try
{
XDocument xDoc = new XDocument();
xDoc = XDocument.Load(RssFeedUrl);
var items = (from x in xDoc.Descendants("item").Take(2)
select new
{
title = x.Element("title").Value,
link = x.Element("link").Value,
pubDate = x.Element("pubDate").Value,
description = x.Element("description").Value
});
foreach (var i in items)
{
Feeds f = new Feeds
{
Title = i.title,
Link = i.link,
PublishDate = i.pubDate,
Description = i.description
};
feeds.Add(f);
}
How to a change this to select 2 random items each time the page is reloaded.
Aucun commentaire:
Enregistrer un commentaire