writing to an RSS file RRS feed

  • Question

  • Hi there,

    So I am doing a little project (just for my own benefit of learning) and I have a created an RSS feed, I used System.ServiceModel.Sydication to create the feed in the first place however now, I just want to add a post to the feed, I don't want to recreate the whole thing each time. I used XLinq to get the current items that are in the feed and now I want to add to it, I can create the new post using that same Syndication namespace however I don't know how to merge the two and save them. Maybe some code will make it easier to see what I am doing...

    //I can easily select the items that are already there
     XDocument feed = XDocument.Load(Server.MapPath("feed.xml"));
     var items = from f in feed.Descendants("item")
                        select f;
    //Now I create the item... 
     SyndicationItem post = new SyndicationItem();
     post.Id = "001";
     post.Title = TextSyndicationContent.CreatePlaintextContent("This is the title...");
      post.Content = TextSyndicationContent.CreateHtmlContent("<p>Hi there...</p>");
     post.PublishDate = DateTime.Now;
     post.Categories.Add(new SyndicationCategory("Test"));
     post.BaseUri = new Uri("http://www.test.net");
      //How to convert items to SydicationItem list? 
    I see a lot of posts about reading RSS feeds but not much about writing to them...

    Thanks for any suggestions.
    • Moved by Harry Zhu Tuesday, February 23, 2010 8:53 AM (From:Visual C# General)
    Friday, February 12, 2010 4:17 PM


All replies