如何从 RSS 提要中仅获取特定类别内的项目
How to get only Items that are within specific Category from RSS Feed
我正在编写一个 RSS-Reader(有点),它应该只输出名为“FF - Titel-Themen”的类别中的项目(Link 到 RSS Feed 是 here).我现在已经搜索了很长时间,但找不到任何东西,因为我对整个 RSS 和 C# 都不熟悉,这并没有让任何事情变得更容易。我希望我的问题有道理...
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
}
}
}
我正在编写一个 RSS-Reader(有点),它应该只输出名为“FF - Titel-Themen”的类别中的项目(Link 到 RSS Feed 是 here).我现在已经搜索了很长时间,但找不到任何东西,因为我对整个 RSS 和 C# 都不熟悉,这并没有让任何事情变得更容易。我希望我的问题有道理...
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
}
}
}