Convert Atom to RSS, vise-versa with 4 lines of WCF code

|  Posted: September 5, 2008  |  Categories: General Technical

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("");
   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.



Author: Saravana Kumar

Saravana Kumar is the Founder and CTO of BizTalk360, an enterprise software that acts as an all-in-one solution for better administration, operation, support and monitoring of Microsoft BizTalk Server environments.

Back to Top