I'm using Argotic Syndication Framework for processing feeds.
But the problem is, if I pass a URL to Argotic, which is not a valid feed (for example, http://stackoverflow.com
which is a html page, not feed), the program hangs (I mean, Argotic stays in an infinity loop)
So, How to check if a URL is pointing to a valid feed?
From .NET 3.5 you can do this below. It will throw an exception if it's not a valid feed.
Or you can try parsing the document by your own:
Then try checking the root element. It should be the feed element and have "http://www.w3.org/2005/Atom" namespace:
References: http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx http://dotnet.dzone.com/articles/systemservicemodelsyndication
If you want to just have it transformed into valid RSS/ATOM, you can use http://feedcleaner.nick.pro/ to have it sanitized. Alternatively, you can fork the project.
you can use Feed Validation Service. It has SOAP API.
You can check the content type. It has to be
text/xml
. See this question to find the content type.you can use this code:
thanks to the answer of the question
Update
To check if it is a feed address you can use W3C Feed Validation service.
Update2
as BurundukXP said it has a SOAP API. to work with it you can read the answer of this question.