Search code examples
phpxmlrssfeedvalidation

Validating an RSS feed


I'm working on an application that allows users to add their own RSS feeds to a simple reader of sorts.

Currently, I'm using xml_domit_rss as the parser but I'm unsure if it's actually validating the URL before parsing.

From what I can gather online, it looks as if validating is separate from the parse, either by using a service https://www.feedvalidator.org or some other method such as parse_url().

Anyone have some insight into either how xml_domit_rss validates, or a method by which I can validate before sending the URL to the parser?


Solution

  • It's simple, You can do that using SyndicationFeed. It supports Atom 1.0 and RSS 2.0 versions.

    try 
    {
        SyndicationFeed fetchedItems = SyndicationFeed.Load(XmlReader.Create(feedUrl));
        // Validation successful.
    } 
    catch { // Validation failed. };