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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:04:30+00:00 2026-05-11T18:04:30+00:00

i’ve been reading through the linq to xml documentation in msdn and some other

  • 0

i’ve been reading through the linq to xml documentation in msdn and some other tutorials and yet i failed to find the right way to do this query as of now 🙁

Basically, i want to loop through each student in the class, for each question, keep a counter of individual skill, i.e. for student 123, the tally should be 001.101.033.002.001 – 1, 001.101.035.002.001 – 1, 001.101.033.002.002 – 0. as the skills counter is based on whether the question is right(1) or wrong(0).

<assessment name="english101" level="primary 6">
   <class id="23" name="1A">
      <student id="123" name="Jack Black">
         <question id="101" correct="1">
            <skill id="001.101.033.002.001" topicId="033" subtopicId="002" subtopicdesc="Launching a browser" topicdesc="Point and Click">Able to recognize and use desktop icon</skill>

            <skill id="001.101.035.002.001" topicId="035" topicDesc="Typing" subtopicId="002" subtopicDesc="Using Words">Able to write on screen</skill>
         </question>

         <question id="102" correct="0">
            <skill id="001.101.033.002.002" topicId="033" subtopicId="002" subtopicdesc="Launching a browser" topicdesc="Point and Click">Able to recognize and use the mouse</skill>

            <skill id="001.101.035.002.001" topicId="035" topicDesc="Typing" subtopicId="002" subtopicDesc="Using Words">Able to write on screen</skill>
         </question>
      </student>

      <student id="124" name="Tim Robbins">
         <question id="103" correct="1">
            <skill id="001.101.033.002.002" topicId="033" subtopicId="002" subtopicdesc="Launching a browser" topicdesc="Point and Click">Able to recognize and use the mouse</skill>

            <skill id="001.101.035.002.001" topicId="035" topicDesc="Typing" subtopicId="002" subtopicDesc="Using Words">Able to write on screen</skill>
         </question>

         <dtasResult>
            <skill id="001.101.033.002.002" result="weak" />

            <skill id="001.101.033.002.002" result="strong" />
         </dtasResult>
      </student>
   </class>
</assessment>

so far the code i have is here:

    //Open up the xml and traverse to the student nodes.
                    XElement root = XElement.Load(fileLocation);
                    IEnumerable<XElement> students = root.Elements("class").Elements("student");

                    string currentStudentId = "";
                    foreach (XElement student in students)
                    {
                        currentStudentId = student.Attribute("id").ToString();
                        //this code chunk below doesn't work!
XElement questions = root.Descendants("question")
                                                .Where(question =>
                                                question.Attribute(""));

                        Console.WriteLine(student.DescendantsAndSelf("question"));
                        Console.WriteLine();
                        Console.WriteLine();
                    }

i have yet to figure out how to do the looping for each question per student.. and the code in the middle of the foraech doesn’t work!!

Updates:

if i wanted to calculate the total question per student, how would i be able to modify your query above to do so? i try grp.Count(z => z.Correct) and other method but i can’t get it right thanks 🙂

  • 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-11T18:04:31+00:00Added an answer on May 11, 2026 at 6:04 pm

    Second edit re comment; I think this does what you want…

    var qry = from cls in doc.Root.Elements("class")
              from student in cls.Elements("student")
              from question in student.Elements("question")
              from skill in question.Elements("skill")
              select new {
                Student = (int)student.Attribute("id"),
                Skill = (string)skill.Attribute("id"),
                Correct = (int)question.Attribute("correct")
              } into denorm
              group denorm by new {
                denorm.Student,
                denorm.Skill
              } into grp
              orderby grp.Key.Student, grp.Key.Skill
              select new {
                grp.Key.Student,
                grp.Key.Skill,
                Tally = grp.Sum(x => x.Correct)
              };
    
    foreach (var row in qry)
    {
      Console.WriteLine("{0}\t{1}\t{2}",
        row.Student, row.Skill, row.Tally);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 99k
  • Answers 99k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To draw on a bitmap you don't want to create… May 11, 2026 at 7:45 pm
  • Editorial Team
    Editorial Team added an answer Setup second level cahce's for all the entities ( check… May 11, 2026 at 7:45 pm
  • Editorial Team
    Editorial Team added an answer If by nest, you mean something like this: #!/bin/bash export… May 11, 2026 at 7:45 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.