验证RSS源URL

时间:2013-05-28 12:41:55

标签: iphone ios rss

我想在我的iPhone应用程序中手动添加RSS提要URL。有没有办法验证RSS提要。我知道可以对URL进行适当的验证,但有没有办法找出给定的URL是否包含正确的RSS / atom?

2 个答案:

答案 0 :(得分:0)

首先,您可以验证天气是否有效。之后,您可以从响应中验证数组计数。因为,如果它不是有效的URL,那么您将不会从响应中获取任何数据..

答案 1 :(得分:0)

取自http://www.haiders.net/post/C-RSS-Feed-Fetcher-Display-RSS-Feed-with-2-lines-of-Code.aspx

//www.haiders.net | Jan 2010
//C# Example: Fetch and Shape RSS Feed
    string rssUri = "http://some.feed.uri.xml";
    var doc = System.Xml.Linq.XDocument.Load(rssUri);
    var rssFeed = from el in doc.Elements("rss").Elements("channel").Elements("item")
          select new { Title = el.Element("title").Value, Link = el.Element("link").Value,
          Description = el.Element("description").Value };
//The data is ready, assuming we have a ListView to display the Feed named lvFeed
//Lets bind the Feed to the ListView
    lvFeed.DataSource = rssFeed;
    lvFeed.DataBind();
//Thats all!