简体   繁体   English

如何从 RSS Feed 中仅获取特定类别中的项目

[英]How to get only Items that are within specific Category from RSS Feed

Im writing an RSS-Reader (sort of) that should only output Items that are within of a Category named "FF - Titel-Themen" (Link to the RSS Feed is here ).我正在编写一个 RSS 阅读器(有点),它应该只 output 属于名为“FF-Titel-Themen”的类别中的项目(链接到 RSS 提要在这里)。 I have search now for quite a time and couldn't find anything and because i´m new to this whole RSS with C# thing its not making anything easier.我现在已经搜索了很长一段时间,但找不到任何东西,因为我是 C# 的整个 RSS 的新手,这并没有让任何事情变得更容易。 I hope my question make sense...我希望我的问题是有道理的...

XmlReader xmlReader = XmlReader.Create("feed url / xml file");
SyndicationFeed RSSFeed = SyndicationFeed.Load(xmlReader);
xmlReader.Close();
List<string> AllCategories = new List<string>();
foreach (SyndicationItem SyndicationItem in RSSFeed.Items)
        {
            foreach (SyndicationCategory category1 in SyndicationItem.Categories)
            {
                if (!Categories_All.Contains(category1.Name))
                {
                    Categories_All.Add(category1.Name);
                }
            }
        }
SyndicationCategory SelectedCategory = new SyndicationCategory("Your specific Category");
        foreach (SyndicationItem SyndicationItem in RSSFeed.Items)
        {
            foreach (SyndicationCategory syndicationCategory in SyndicationItem.Categories)
            {
                if (syndicationCategory.Name == SelectedCategory.Name)
                {
                    // DO STUFF WHAT YOU WANT TO DO WITH THE ITEMS
                }
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM