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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:37:45+00:00 2026-05-20T05:37:45+00:00

My LINQ Query is only returning the first result (Class). Here is the code

  • 0

My LINQ Query is only returning the first result (Class). Here is the code that I am using:

        XDocument xmlDoc = XDocument.Load("Decks/Test.xml");
        List<Cards> tempdeck = (from deck in xmlDoc.Elements("Deck")
                                select new Cards
                                 {
                                     Name = deck.Element("Type").Value

                                 }).ToList<Cards>();

        foreach (var item in tempdeck)
        {
            ((MessageBroker)App.Current.Resources["MessageBroker"]).GameLog.Add(item.Name.ToString());

        }

This is what my XML file looks like:

<Deck>
  <Type>
    <Name>Class</Name>
  </Type>
  <Type>
    <Name>stsfs</Name>
  </Type>
  <Type>
    <Name>Class</Name>
  </Type>
  <Type>
      <Name>Class</Name>
    </Type>
</Deck>

I am formatting it this way because when I get it to work I want to add multiple properties to the query – not just name.

Thanks in advance!

  • 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-20T05:37:46+00:00Added an answer on May 20, 2026 at 5:37 am

    It isn’t clear from your sample, but it appears you have one Deck element with multiple Type child elements. Your code is assuming the opposite, i.e. multiple decks, each with one (or one interesting) type-child.

    Try this instead:

    ( from type in xmlDoc.Element("Deck").Elements("Type")
      select new Cards { Name = type.Value }
    ).ToList()
    

    A “cards” is produced from each type-child of the only deck.

    If you do have multiple decks, go with Mark Cidade’s answer.

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

Sidebar

Related Questions

I am returning two lists from the database using LINQ to SQL compiled query.
I have a linq query and I am trying to put that in to
I have a pretty complicated Linq query that I can't seem to get into
I have the following LINQ query. The problem is it's returning 13k results when
I have the below LINQ that is returning zero IF there aren't any Addresses(Inner
I have a LINQ query I wish to run and drop the result into
I'm trying to write a LINQ query that that simply gets the count of
I'm struggling with an exception using linq-to-sql Concat() I've got 2 tables. The first
I have a Linq query that returns an anonymous type, which I then use
Can a Linq query retrieve BLOBs from a Sql Database? And how do they

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.