【发布时间】:2009-01-08 17:13:27
【问题描述】:
您好,我正在为医学研究编写应用程序 他们将输入 性别、年龄和其他一些将被计算为 ResultValue 的值
现在我有一个 XML 文件,其中包含有关结果的一些信息 年龄,性别和结果值,我想打印出测试结果的描述(如果先证者属于哪个组) 需要注意的一件事是我必须处理值范围,这意味着实际值介于低部分和高部分之间...... 我有三组... 好的,这是我的 XML 文件
<?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>
如果我有,我的 linq to xml 查询会是什么样子
性别=“女性”
年龄=29
结果值=17
这个先证者肯定属于第 1 组,我想 打印出匹配的描述...
但我正在努力让这个工作......
我正在寻找 C# 中的解决方案... 任何帮助都会很棒!!!
【问题讨论】:
-
您是在寻找 VB.Net LINQ to XML 查询还是 C# 查询。非常不同的答案。
-
哦,对不起!我正在寻找一个 c# 解决方案...