Click here to Skip to main content
13,049,722 members (64,924 online)
Click here to Skip to main content
Add your own
alternative version


8 bookmarked
Posted 24 Oct 2007

ATOM To RSS Converter

, 24 Oct 2007
Rate this:
Please Sign up or sign in to vote.
This article will help you to find a way to convert the ATOM to RSS Feed Format


Today we know Feeds play a major role in sharing information. RSS makes it possible for people to keep up with their favorite Web sites in an automated manner that's easier than checking them manually.

Along with these, there came many other versions like RDF, ATOM. The code provided here can help in converting the RDF Feeds to the RSS Feed format.

Using the Code

Here the code accepts the ATOM content as the argument and then returns the XML Content which is in the RSS Feed format:

public string AtomToRssConverter(XmlDocument atomDoc)
            XmlDocument xmlDoc = atomDoc;
            XmlNamespaceManager mgr = new XmlNamespaceManager(xmlDoc.NameTable);
            mgr.AddNamespace("atom", "");
            const string rssVersion = "2.0";
            const string rssLanguage = "en-US";
            string rssGenerator = "RDFFeedConverter";
            MemoryStream memoryStream = new MemoryStream();
            XmlTextWriter xmlWriter = new XmlTextWriter(memoryStream, null);
            xmlWriter.Formatting = Formatting.Indented;
            string feedTitle = xmlDoc.SelectSingleNode("//atom:title", mgr).InnerText;
            string feedLink = xmlDoc.SelectNodes("//atom:link/@href", mgr)[2].InnerText;
            string rssDescription = xmlDoc.SelectSingleNode
				("//atom:tagline", mgr).InnerText;
            xmlWriter.WriteAttributeString("version", rssVersion);
            xmlWriter.WriteElementString("title", feedTitle);
            xmlWriter.WriteElementString("link", feedLink);
            xmlWriter.WriteElementString("description", rssDescription);
            xmlWriter.WriteElementString("language", rssLanguage);
            xmlWriter.WriteElementString("generator", rssGenerator);
            XmlNodeList items = xmlDoc.SelectNodes("//atom:entry", mgr);
            if (items == null)
                throw new FormatException("Atom feed is not in expected format. ");
                string title = String.Empty;
                string link = String.Empty;
                string description = String.Empty;
                string author = String.Empty;
                string pubDate = String.Empty;
                for (int i = 0; i < items.Count; i++)
                    XmlNode nodTitle = items[i];
                    title = nodTitle.SelectSingleNode("atom:title", mgr).InnerText;
                    link = items[i].SelectSingleNode("atom:link[@rel='alternate']", 
                    description = items[i].SelectSingleNode("atom:content", 
                    author = items[i].SelectSingleNode("//atom:name", mgr).InnerText;
                    pubDate = items[i].SelectSingleNode("atom:issued", mgr).InnerText;
                    xmlWriter.WriteElementString("title", title);
                    xmlWriter.WriteElementString("link", link);
			(@"ddd, dd MMM yyyy HH:mm:ss G\MT"));
                    xmlWriter.WriteElementString("author", author);
                    xmlWriter.WriteElementString("description", description);
            XmlDocument retDoc = new XmlDocument();
            string outStr = Encoding.UTF8.GetString(memoryStream.ToArray());
            return outStr;

Points of Interest

I have only tried to extract Title, Description, Time, Author, and Link. You can extend that at any point of time. I have even tried to save the converted content. If you wish, you can remove that statement in the code.


  • 24th October, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Govardhana Reddy
Web Developer India
India India
This is Govardhana Reddy, i am here to explore this world of INTERNET. I feel this is one way through which i can explore this world of INTERNET.

I want to be one among the best in this profession (a Software Developer, not a Software Engineer its a bit Controversial.) if not the "BEST"

My definition of a Software Engineer : "A person who knows what to cut/copy and where to paste".

Apart from my technical stuff I love Long Drives, Computer Gaming, Sports, Bikes and much more to say.

Anyways long road ahead keep me accompanied...

You may also be interested in...

Comments and Discussions

QuestionWhy anybody would want to do it? Pin
chopeen24-Oct-07 20:57
memberchopeen24-Oct-07 20:57 
AnswerRe: Why anybody would want to do it? Pin
Riaan Lehmkuhl19-Jul-08 0:00
memberRiaan Lehmkuhl19-Jul-08 0:00 
One never knows when you'll get to need anything. Just because you don't need it now, doesn't mean you won't need it later.
You can come back here if you want to move your blogger blog to BlogEngine.NET[^].

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 25 Oct 2007
Article Copyright 2007 by Govardhana Reddy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid