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

  • Home
  • SEARCH
  • 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 195289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:40:05+00:00 2026-05-11T16:40:05+00:00

want to query below xml <courseList filedUnder=Courses> <category code=4wd title=4wd Operation> <product code=lr title=4wd

  • 0

want to query below xml

 <courseList filedUnder="Courses">
  <category code="4wd" title="4wd Operation">
    <product code="lr" title="4wd Bush Driving">
        <duration>1 Day</duration> 
    </product>
    <product code="hr" title="4wd Defensive Driving">
        <duration>1 Day</duration> 
    </product>
    <product code="sr" title="Self-Recovery">
        <duration>1 Day</duration> 
    </product>
  </category>
 </courseList>

for now am doing something below:

      var list = (from x in xd.Descendants("product").Attributes("title")  
      select new { Title= x.Value}).ToList();

which returns just : title value

What i want is in same query to return Duration value too.

How can this be achieved.

Thanks

  • 1 1 Answer
  • 1 View
  • 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-11T16:40:06+00:00Added an answer on May 11, 2026 at 4:40 pm

    Currently you’re selecting the attributes instead of the elements. To include the duration, you’ll need the whole element.

    var list = xd.Descendants("product")
                 .Select(element => new 
                     { Title = element.Attribute("title").Value,
                       Duration = element.Element("duration").Value })
                 .ToList();
    

    (Note that this doesn’t do any sort of error checking – there’d better be a title attribute and a duration element…)

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

Sidebar

Related Questions

I've got a query below. I want to add a condition that if the
I am doing project in cakephp . I want to write below query in
hopefully you can get what I want to do from the mysql query below.
I have trouble working with xml query. Below is the xml document. All I
In the below query I want to add an AND condition inside the CASE's
Below is the XML file - <Chapters> <Chapter> <Name>Introduction</Name> <Heads> <Head> <No>1</No> <Title>History of
I have an operation contract (below) that I want to allow GET and POST
I'm accepting dates from a wicket form - now I want query my DAO
I want to query the name of all columns of a table. I found
I want DBSession.query(Article).group_by(Article.created.month).all() But this query can't using How do I do this using

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.