Click here to Skip to main content
11,921,889 members (59,210 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


12 bookmarked

How to Read Twitter Feeds With LINQ to XML

, 19 Apr 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
Twitter feeds are provided in RSS XML format. This makes it very easy for us to parse out the information we want from a feed using LINQ to XML.

Twitter feeds are provided in RSS XML format. This makes it very easy for us to parse out the information we want from a feed using LINQ to XML. For example, if we want to grab the message and date of each Twitter entry, we could use something like this:

public class Twitter
    public string Message { get; set; }
    public DateTime PubDate { get; set; }

    public static List<Twitter> Parse(string User)
        var rv = new List<Twitter>();
        var url = "" + User + ".rss";
        var element = XElement.Load(url);
        foreach (var node in element.Element("channel").Elements("item"))
            var twit = new Twitter();
            var message = node.Element("description").Value;

            //remove username information
            twit.Message = message.Replace(User + ": ", string.Empty);
            twit.PubDate = DateTime.Parse(node.Element("pubDate").Value);

        return rv;

You can get the Twitter feeds by using the following:

var fromTwitter = Twitter.Parse("Merlin981");


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


About the Author

Software Developer (Senior)
United States United States
Winner - Best Mobile App - AT&T Developer Summit, Las Vegas, 2013

My personal resume can be found at:

My game portfolio can be found at:

About Philip Pierce:

I am a software developer with twenty years experience in game development, mobile, web, desktop, server, and database. My extensive background highlights an expertise in rapid application development using the latest Microsoft, Mobile, and Game Development technologies, along with the ability to create AI for games and business software, redesign existing software, develop multi-threaded software, and create client/server applications.

You may also be interested in...

Comments and Discussions

QuestionWhere did you use LINQ ? Pin
bjuretko28-Apr-09 5:05
memberbjuretko28-Apr-09 5:05 
Questionwhy use loop? Pin
Grzesiek19-Apr-09 13:22
memberGrzesiek19-Apr-09 13:22 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151120.1 | Last Updated 19 Apr 2009
Article Copyright 2009 by merlin981
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid