SyndicationFeed feed = new SyndicationFeed("My Feed", "This is a sample feed", new Uri("http://example.com/")); feed.Authors.Add(new SyndicationPerson("[email protected]", "Author", "http://example.com")); feed.Categories.Add(new SyndicationCategory("Technology")); feed.Items = new List{ new SyndicationItem("Item 1","Content for item 1",new Uri("http://example.com/item1"), "item1ID", DateTime.Now), new SyndicationItem("Item 2","Content for item 2",new Uri("http://example.com/item2"), "item2ID", DateTime.Now), };
XmlReader reader = XmlReader.Create("http://example.com/feed.xml"); SyndicationFeed feed = SyndicationFeed.Load(reader); foreach (var item in feed.Items) { Console.WriteLine(item.Title.Text); Console.WriteLine(item.Summary.Text); Console.WriteLine(item.Links[0].Uri.AbsoluteUri); }This code loads an RSS or Atom feed from a URL, creates a SyndicationFeed object from it, and loops through its items. For each item, it outputs the title, summary, and link. In conclusion, System.ServiceModel.Syndication is a package library in C# that provides functionality for creating and consuming RSS and Atom feeds. The SyndicationFeed class is used to represent a feed, and we demonstrated its usage with two code examples.