2017-06-06 57 views
0

使用此命令,我搜索一個網址的所有物品,他尋找10個物品,現在我需要使用此命令從第五個位置僅選擇物品, 只返回一個物品,這個使用下面的命令,我可以做的,什麼樣的變化,我應該讓接收來自XAMARIN飼料的物品

private async Task<List<FeedItem>> ParseFeed(string rss) 
{ 
    return await Task.Run(() => 
    { 
     var xdoc = XDocument.Parse(rss); 
     var id = 0; 
     return (from item in xdoc.Descendants("item") 
       let enclosure = item.Element("enclosure") 
       where enclosure != null 
       select new FeedItem 
       { 
        Title = (string)item.Element("title"), 
        Description = (string)item.Element("description"), 
        Link = (string)item.Element("link"), 
        PublishDate = DateTime.Parse((string)item.Element("pubDate")).ToUniversalTime().ToString("dd/MM/yyyy HH:mm:ss"), 
        Category = (string)item.Element("category"), 
        Mp3Url = (string)enclosure.Attribute("url"), 
        Image = (string)enclosure.Attribute("url"), 
        Color_category =Convert.ToString(int.Parse((string)item.Element("color")), 16).PadLeft(6, '0'), 
       Id = id++ 
       }).ToList(); 
    }); 
} 

回答

1

使用跳過()和Take()

return (from item in xdoc.Descendants("item") 
    ... 
    }).Skip(4).Take(1).ToList();