Reading non-standard elements in a SyndicationItem with SyndicationFeed

前端 未结 5 642
挽巷
挽巷 2020-12-02 09:08

With .net 3.5, there is a SyndicationFeed that will load in a RSS feed and allow you to run LINQ on it.

Here is an example of the RSS that I am loading:

<         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 09:26

    This should give you an idea on how to do it:

    using System.Linq;
    using System.ServiceModel.Syndication;
    using System.Xml;
    using System.Xml.Linq;
    

    SyndicationFeed feed = reader.Read();
    
    foreach (var item in feed.Items)
    {
        foreach (SyndicationElementExtension extension in item.ElementExtensions)
        {
            XElement ele = extension.GetObject();
            Console.WriteLine(ele.Value);
        }
    }
    

提交回复
热议问题