Published on : Sep 5, 2008
Category : General
Working with different Syndication format is a real pain, most of the time applications utilizing Syndications converts them to one format to keep their object model simple. This is the technique I used in BizTalk 247
blog aggregator and
blogDoc.
Converting from one format to another is a real pain, you need to use either custom XSL or your own object mapping.
Not anymore if you got WCF SP1, with the introduction of
System.ServiceModel.Syndication it abstracts all the underlying format and gives a nice object model to work with. The following 4 lines of code will be sufficient to convert from one format to another.
1: XmlReader reader = XmlReader.Create("http://blogs.msdn.com/darrenj/rss.xml");
2: SyndicationFeed feed = SyndicationFeed.Load(reader);
3: using(XmlWriter writer = XmlWriter.Create(@"c:Darren_Atom_10.xml"))
4: {
5: feed.SaveAsAtom10(writer);
6: }
By using “SaveAsRSS20(Writer)” you can save Atom to RSS.
Nandri!
Saravana