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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:37:19+00:00 2026-05-11T01:37:19+00:00

Hi I am writing an app for a medical study they will type in

  • 0

Hi I am writing an app for a medical study they will type in the gender, the age, and some other values which will be calculated to a ResultValue

now I have an XML file which holds some information about the result in combination of Age, Gender and the ResultValues and I would like to print out the description of the TestResult (in case in which group the proband belong) One thing to note is that I have to deal with value ranges this means the actual value lies between the low part and the high part… I have three groups… OK hier is my XML file

<?xml version='1.0' encoding='iso-8859-1'?>  <Result>         <ID>1</ID>         <Description>You belong to Group 1</Description>         <Genders>             <Gender type='female'>                 <Ages>                     <Age low='18' high='24'>                         <ResultValue low='0' high='19'/>                     </Age>                     <Age low='25' high='34'>                         <ResultValue low='0' high='20'/>                     </Age>                     <Age low='35' high='44'>                         <ResultValue low='0' high='21'/>                     </Age>                     <Age low='45' high='54'>                         <ResultValue low='0' high='22'/>                     </Age>                     <Age low='55' high='64'>                         <ResultValue low='0' high='23'/>                     </Age>                     <Age low='65' high='110'>                         <ResultValue low='0' high='24'/>                     </Age>                 </Ages>             </Gender>             <Gender type='male'>                 <Ages>                     <Age low='18' high='24'>                         <ResultValue low='0' high='19'/>                     </Age>                     <Age low='25' high='34'>                         <ResultValue low='0' high='20'/>                     </Age>                     <Age low='35' high='44'>                         <ResultValue low='0' high='21'/>                     </Age>                     <Age low='45' high='54'>                         <ResultValue low='0' high='22'/>                     </Age>                     <Age low='55' high='64'>                         <ResultValue low='0' high='23'/>                     </Age>                     <Age low='65' high='110'>                         <ResultValue low='0' high='24'/>                     </Age>                 </Ages>             </Gender>         </Genders>     </Result>     <Result>         <ID>2</ID>         <Description>You belong to Group 2</Description>         <Genders>             <Gender type='female'>                 <Ages>                     <Age low='18' high='24'>                         <ResultValue low='19' high='24'/>                     </Age>                     <Age low='25' high='34'>                         <ResultValue low='20' high='25'/>                      </Age>                     <Age low='35' high='44'>                         <ResultValue low='21' high='26'/>                     </Age>                     <Age low='45' high='54'>                         <ResultValue low='22' high='27'/>                     </Age>                     <Age low='55' high='64'>                         <ResultValue low='23' high='28'/>                     </Age>                     <Age low='65' high='110'>                         <ResultValue low='24' high='29'/>                     </Age>                 </Ages>             </Gender>             <Gender type='male'>                 <Ages>                     <Age low='18' high='24'>                         <ResultValue low='19' high='24'/>                     </Age>                     <Age low='25' high='34'>                         <ResultValue low='20' high='25'/>                     </Age>                     <Age low='35' high='44'>                         <ResultValue low='21' high='26'/>                     </Age>                     <Age low='45' high='54'>                         <ResultValue low='22' high='27'/>                     </Age>                     <Age low='55' high='64'>                         <ResultValue low='23' high='28'/>                     </Age>                     <Age low='65' high='110'>                         <ResultValue low='24' high='29'/>                     </Age>                 </Ages>             </Gender>         </Genders>     </Result>     <Result>         <ID>3</ID>         <Description>You belong to group 3</Description>         <Genders>             <Gender type='female'>                 <Ages>                     <Age low='18' high='24'>                         <ResultValue low='24' high='29'/>                     </Age>                     <Age low='25' high='34'>                         <ResultValue low='25' high='30'/>                      </Age>                     <Age low='35' high='44'>                         <ResultValue low='26' high='31'/>                     </Age>                     <Age low='45' high='54'>                         <ResultValue low='27' high='32'/>                     </Age>                     <Age low='55' high='64'>                         <ResultValue low='28' high='33'/>                     </Age>                     <Age low='65' high='110'>                         <ResultValue low='29' high='34'/>                     </Age>                 </Ages>             </Gender>             <Gender type='male'>                 <Ages>                     <Age low='18' high='24'>                         <ResultValue low='24' high='29'/>                     </Age>                     <Age low='25' high='34'>                         <ResultValue low='25' high='30'/>                     </Age>                     <Age low='35' high='44'>                         <ResultValue low='26' high='31'/>                     </Age>                     <Age low='45' high='54'>                         <ResultValue low='27' high='32'/>                     </Age>                     <Age low='55' high='64'>                         <ResultValue low='28' high='33'/>                     </Age>                     <Age low='65' high='110'>                         <ResultValue low='29' high='34'/>                     </Age>                 </Ages>             </Gender>         </Genders>        </Result> 

What would look my linq to xml query like if I have

gender=’female’

age=29

ResultValue=17

this proband would certainly belong to Group 1 and I would like to print out the matching Description…

But I am banging my head to get this working…

I am looking for a solution in c#… Any help would be great!!!

  • 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. 2026-05-11T01:37:19+00:00Added an answer on May 11, 2026 at 1:37 am

    Something like this?

    XElement myElement = XElement.Parse(xmlstring);  int resultValue = 17; int age = 26; string genderValue = 'female';  IEnumerable<string> query =     myElement.Descendants('ResultValue')         .Where(rv => ((int)rv.Attribute('low')) <= resultValue)         .Where(rv => ((int)rv.Attribute('high')) >= resultValue)         .Where(rv => rv.Ancestors('Age')             .Any(a => ((int) a.Attribute('low')) <= age && ((int) a.Attribute('high')) >= age)         )        .Where(rv => ((string)rv.Ancestors('Gender').Single().Attribute('type')) == genderValue)        .Select(rv => rv.Ancestors('Result').Single().Element('Description').Value);      foreach (string x in query)         Console.WriteLine(x); 

    The idea is that you can imagine a row-column shape where each row is a ResultValue. Each result value has a single parent of Age, a single parent of Gender, an a single parent of Result.

    ResultValue.Low ResultValue.High Age.Low Age.High Gender.Type Result.Description

    In fact, one can project the above xml into that shape:

            var query2 = myElement.Descendants('ResultValue')             .Select(rv => new              {                 ResultValue = rv,                 Age = rv.Ancestors('Age'),                 Gender = rv.Ancestors('Gender'),                 Result = rv.Ancestors('Result')             })             .Select(x => new XElement('Data',             new XAttribute('ResultValue.Low', (int)x.ResultValue.Attribute('low')),             new XAttribute('ResultValue.High', (int)x.ResultValue.Attribute('high')),             new XAttribute('Age.Low', (int)x.Age.Attributes('low').Single()),             new XAttribute('Age.High', (int)x.Age.Attributes('high').Single()),             new XAttribute('Gender.Type', (string) x.Gender.Attributes('type').Single()),             new XAttribute('Result.Description', (string) x.Result.Elements('Description').Single())             ));         foreach (XElement x in query2)             Console.WriteLine(x); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app which will remove some Registry keys recursively using API
so i am writing an app for android which will push some data over
im writing c# app in VS2008 that will use some reports. My question: how
I'm writing an app which will rely heavily on the use of a database.
I'm writing an app in which there will be user defined categories which will
Writing an app which takes the preview frames from camera does some transformation to
I'm writing an app in Hebrew (which is rtl). when I set my title
I'm writing an app which plays host to a series of plug-ins. Those plug-ins
I'm writing an app with GWT, which I want to deploy to Google App
Im writing app in haskell and I would like to export some functions and

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.