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

前端 未结 5 1563
小鲜肉
小鲜肉 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:03

    Use this :

    private string GetAlbumRSS(SyndicationItem album)
        {
    
            string url = "";
            foreach (SyndicationElementExtension ext in album.ElementExtensions)
                if (ext.OuterName == "itemRSS") url = ext.GetObject();
            return (url);
    
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string albumRSS;
            string url = "http://www.SomeSite.com/rss‎";
            XmlReader r = XmlReader.Create(url);
            SyndicationFeed albums = SyndicationFeed.Load(r);
            r.Close();
            foreach (SyndicationItem album in albums.Items)
            {
    
                cell.InnerHtml = cell.InnerHtml +string.Format("
    {1}", album.Links[0].Uri, album.Title.Text); albumRSS = GetAlbumRSS(album); } }

提交回复
热议问题