I want to manually add RSS feed URL in my iPhone App. Is there any way to validate RSS feed. I know that proper validation of URL can be done, but there any way to find out whether given url contains proper RSS/atom?
3
-
Can you please tell me which RSS parser, you are using in your application?– iPhone developer.Commented May 28, 2013 at 12:45
-
In my case, I get RSS data from server in JSON format and from there I parse it– iCoder4777Commented May 28, 2013 at 12:47
-
@iCoder4777 You should simply parse the feed, and if you have the required elements, you can infer that you probably have an appropriate RSS/atom. If you are missing required elements, then you don't.– RobCommented May 28, 2013 at 13:07
Add a comment
|
2 Answers
First you can verify as weather it is valid URL or not. and after it you can verify array count fromt your response. Because, if it is not valid URL, then you will not get any data from response..
-
:-Don't worry, I will try and if this logic works or I will not get any other relevent answer then ur answer will be accepted. Commented May 28, 2013 at 13:01
Taken from 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!