Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4238820
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:57:14+00:00 2026-05-21T02:57:14+00:00

I have an application that I’m writing that allows users to search Twitter, written

  • 0

I have an application that I’m writing that allows users to search Twitter, written mainly just for fun and learning about how XML and LINQ play together. I’ve written code to fetch the atom feed (example query: http://search.twitter.com/search.atom?q=twitter), and I can verify that it is, in fact, receiving XML.

Just to get started with parsing the document, I figured it would be simple enough to just parse out the content of each tweet. Once I verify that works, then I would move on to the author, then date, and so on and so forth until everything is parsed.

Here is what I’m using to get the content:

            var list = from tweet in doc.Element("feed").Descendants("entry")
                       select new Tweet("AUTHOR", tweet.Element("content").Value, new DateTime(), "TITLE");

As you can see, the document structure looks something like this:

<feed><entry><content></content></entry>.....</feed>

At least as far as we are concerned. I get a NullReferenceException on this line of code, but the debugger shows that the document is not null (it does in fact have the whole feed loaded in it). The previous line calls XDocument.Parse(), which throws no exceptions.

Does anyone know what could be causing my downfall?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:57:15+00:00Added an answer on May 21, 2026 at 2:57 am

    The feed element includes this:

    xmlns="http://www.w3.org/2005/Atom"
    

    which changes the default namespace for the elements. You should use that like this:

    XNamespace ns = "http://www.w3.org/2005/Atom";
    var list = from tweet in doc.Element(ns + "feed")
                                .Descendants(ns + "entry")
               select new Tweet("AUTHOR", 
                                tweet.Element(ns + "content").Value,
                                new DateTime(), "TITLE");
    

    (Just to explain, you were looking for a namespace-less “feed” element; that didn’t exist, so Element returned null. If you’d fixed just that, Descendants would have returned an empty sequence. If you’d fixed those two, tweet.Element("content") would have returned null, causing a different NullPointerException.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have network application that handles about 40k msg/sec written using netty framework and
I have an application that allows users to upload files. Some of these files
I have android application that is written regular way. layouts, java, APK. Now, depending
I have an application that allows, using an abstract class, people to write their
I have an application that I am just migrating to Azure. Currently I use
I have an application that lets users record video from their webcams. The users
I have application that makes different queries with different results so the caching in
I have application that is connecting to the DB and if I enter incorrect
I have application that is up more than 3 days. I can see in
I have application that brings response via Ajax and creates 5-20 new jQuery click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.