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("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

Author: Saravana Kumar

Saravana Kumar is the Founder and CTO of BizTalk360 | Serverless360 | Atomic Scope | Document360. Founder of multiple B2B products that solve the pain point of enterprise customers. Entrepreneur, Investor and Technical enthusiast. Passionate about running and scaling a company in a profitable way with calculated risks.

Back to Top