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 7959735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:37:10+00:00 2026-06-04T04:37:10+00:00

In this question , if I need to get date included in the output,

  • 0

In this question, if I need to get “date” included in the output, what changes should be made?

When I included

let dt = l.Element("Date").Value

It gives, “Object reference not set to an instance of an object”

var query = from l in doc.Descendants("L1")
            let dt = l.Element("Date").Value
            let id = l.Attribute("id").Value
            from subject in l.Descendants("Subject")
            select new
            {
                Date = dt,
                Id = id,
                SubjectName = (string)subject.Attribute("SubjectName"),
                Score = (string)subject.Attribute("Score")
            };


foreach (var result in query)
{
    Console.WriteLine(result);
}
  • 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-06-04T04:37:11+00:00Added an answer on June 4, 2026 at 4:37 am

    Looking at your other XML, it does not, as Mr. Skeet mentioned, have anything in the <date> elements. You will need to explicitly handle that if you aren’t planning on always having data in there.

    You can do something like this:

    let dt = l.Element("date") == null ? string.Empty : l.Element("date").Value 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is driving me crazy. I need to get it right so I
For reasons that are irrelevant to this question I'll need to run several SQLite
This question is geared towards a group of newly hired developers that need to
This question is more about guidance than actually solving my problem: I need to
This question is not about caching. I need this in-memory table for many small
Disclaimer: this question is driven by my personal curiosity more than an actual need
I really need an answer to this question. I am working on a project
This question is regarding getopt function in php. I need to pass two parameter
After reading this question, I need to clear up some things. IQueryable<Customer> custs =
I know this question is difficult to understand but I need a mathematical equation

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.