Best Way to read rss feed in .net Using C#

前端 未结 5 1574
小鲜肉
小鲜肉 2020-11-29 16:25

What is the best way to read RSS feeds?

I am using XmlTextReader to achieve this. Is there any other best way to do it?

XmlText         


        
5条回答
  •  生来不讨喜
    2020-11-29 17:05

    Add System.ServiceModel in references

    Using SyndicationFeed:

    string url = "http://fooblog.com/feed";
    XmlReader reader = XmlReader.Create(url);
    SyndicationFeed feed = SyndicationFeed.Load(reader);
    reader.Close();
    foreach (SyndicationItem item in feed.Items)
    {
        String subject = item.Title.Text;    
        String summary = item.Summary.Text;
        ...                
    }
    

提交回复
热议问题