Serializing RSS Feed to ASP.NET

I would like the user to specify the address of the RSS feed and serialize the information from it. I'm not interested in the XML format, but it populates a strongly typed object from XML. My question is, is there a standard that supports all RSS feeds (do they all have a date, name, etc.)? If yes, then there is an XSD that describes this. If not, how do I handle serialization of an RSS feed for an object in ASP.NET?

EDIT: SyndicationFeed elements have the following properties:

  • Title.Text → Gives us the title
  • Summary.Text → Gives a summary

Q1 - Summary includes html tags. Is there any way to remove them? I'm only interested in the text of Q2. Do all RSS feeds have full content in the Summary element? I see that some RSS feeds have only a few lines for resumes, while others have all the content of the message. Thanks

+3
source share
6 answers

if you reference System.ServiceModel.Web, there are some options for getting a feed into a strongly typed object

using (var reader = XmlReader.Create(@"http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml"))
{
    var feed = SyndicationFeed.Load(reader);
    if (feed != null)
    {
        foreach (var item in feed.Items)
        {
            Console.WriteLine(item.Title.Text);
        }
    }
}
+3
source

Yes RSS is a standard format.

If you are looking for a “C # RSS Reader”, you will find many implementations of helper objects that will bring you information from the feed.

Linq XML, XML. , .

0

.NET Framework 3.5 . , .

3.5, Atom.NET (: 6 ).

0

, W3C, RSS 2.0. RSS 0.91, 0.92 2.0 .

.Net RSS.Net .

0

Argotic framework. , RSS-.

0

:

    public object getRSS(string url)
{
    XDocument feedXML = XDocument.Load(url);
    var feeds = from feed in feedXML.Descendants("item")
                select new
                {
                    Title = feed.Element("title").Value,
                    Link = feed.Element("link").Value,
                    Description = feed.Element("description").Value,
                };

    return feeds;
}
0

Source: https://habr.com/ru/post/1746472/


All Articles