简体   繁体   中英

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 ). 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. 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
                }
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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