按名称分组并在 linq to xml c# 中包含重复数据
我开始在工作中学习 asp.net 和 c#,并且我得到了一个在 asp.net 中创建和修复网页的项目。
我在使用将 xml 数据显示到网页的功能之一时遇到问题。
代码的目的是在顶部获取最新记录(日期和非时间),而同一节点具有相同通用名称的其余记录将在下面。
问题是,目前如果有两个以上的节点具有相同的值和相同的日期,它将拆分并对待不同的项目,并且它将创建两个具有两个不同顶级项目的组。
代码:
var xd = XDocument.Parse(element.OuterXml);
if (xd != null)
{
var results =
(from el1 in xd.Descendants("Microbiology")
from el2 in el1.Descendants("Test")
orderby el2.Element("Date").Value descending
//orderby el2.Element("Rubric").Value
// I tried using distinct here but does not work.
where el2.Element("Date").Value ==
(el1.Descendants("Test").Where(
e => e.Element("ReadCode").Value ==
el2.Element("ReadCode").Value).First().Element("Date").Value)
select new Microbiology
{
Date = el2.Element("Date") != null ? el2.Element("Date").Value : "",
ReadCode = el2.Element("ReadCode") != null
? el2.Element("ReadCode").Value
: "",
Rubric = el2.Element("Rubric") != null
? el2.Element("Rubric").Value
: "",
SubMicro = (from subMicroEl1 in xd.Descendants("Microbiology")
from subMicroEl2 in subMicroEl1.Descendants("Test")
orderby subMicroEl2.Element("Date").Value descending
orderby subMicroEl2.Element("Rubric").Value
where subMicroEl2.Element("Rubric").Value ==
el2.Element("Rubric").Value &&
subMicroEl2.Element("Date").Value !=
el2.Element("Date").Value
select new Microbiology
{
Date = subMicroEl2.Element("Date") != null
? subMicroEl2.Element("Date").Value
: "",
ReadCode = subMicroEl2.Element("ReadCode") != null
? subMicroEl2.Element("ReadCode").Value
: "",
Rubric = subMicroEl2.Element("Rubric") != null
? subMicroEl2.Element("Rubric").Value
: "",
}).ToList<Microbiology>()
});
XML:
<Microbiology>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value>123</Value>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value>123123</Value>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-30</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-30</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-30</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-30</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-05-12</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-05-12</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-05-12</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-05-12</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-03-07</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-03-07</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-03-07</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-03-07</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-11-07</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-11-07</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-11-07</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-11-07</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-08-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-08-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-06-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-06-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-06-13</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-06-13</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-05-04</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-05-04</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-05-04</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-05-04</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-01-26</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-01-26</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-09-29</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-09-29</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-31</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-31</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-31</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-31</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-16</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-16</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-16</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-16</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-06-02</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-06-02</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-06-02</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-06-02</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-05-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-05-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-05-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-05-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-01-17</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-01-17</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-11-22</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-11-22</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-10-18</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-10-18</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-10-18</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-10-18</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-07-19</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-07-19</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-07-19</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-07-19</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-03-15</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-03-15</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-03-15</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-03-15</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2003-10-06</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2003-10-06</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2003-01-20</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2003-01-20</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2002-06-17</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2002-06-17</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>1998-04-02</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2002-04-02</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2002-01-09</Date>
<ReadCode>4JG6.</ReadCode>
<Rubric>Skin swab culture positive</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-01-08</Date>
<ReadCode>4JG6.</ReadCode>
<Rubric>Skin swab culture positive</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-12-05</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-12-03</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-12-03</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-12-03</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-10-01</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-10-01</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-07-06</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-06-12</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-06-12</Date>
<ReadCode>4JG5.</ReadCode>
<Rubric>Skin swab culture negative</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-05-22</Date>
<ReadCode>4JG6.</ReadCode>
<Rubric>Skin swab culture positive</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2000-11-10</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2000-09-19</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2000-06-07</Date>
<ReadCode>4JP..</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus positive</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2000-01-31</Date>
<ReadCode>4JG6.</ReadCode>
<Rubric>Skin swab culture positive</Rubric>
<Value/>
<Units/>
</Test>
</Microbiology>
我有点明白代码的作用,但我不知道如何修改它。
更新 我需要的是按 Rubric 或 ReadCode 对它们进行分组,并按日期对它们进行排序,即使日期重复,我也只需要一组和其中的所有元素,其中最新日期位于顶部。
任何帮助将不胜感激。
如果您需要更多信息,请告诉我,我会继续检查该问题。
提前致谢。
I'm starting to learn asp.net and c# at work and I've been given a project to create and fix web pages in asp.net.
I am having trouble with one of the functions to display the data from xml to web page.
The intention of the code is to get the latest record(date and no time) at the top and the rest of records with same common name for same node will go below.
The problem is that at the moment if there are more than two nodes with same values and same dates it will split and treat like to different items and it will create two groups with two different top items.
Code:
var xd = XDocument.Parse(element.OuterXml);
if (xd != null)
{
var results =
(from el1 in xd.Descendants("Microbiology")
from el2 in el1.Descendants("Test")
orderby el2.Element("Date").Value descending
//orderby el2.Element("Rubric").Value
// I tried using distinct here but does not work.
where el2.Element("Date").Value ==
(el1.Descendants("Test").Where(
e => e.Element("ReadCode").Value ==
el2.Element("ReadCode").Value).First().Element("Date").Value)
select new Microbiology
{
Date = el2.Element("Date") != null ? el2.Element("Date").Value : "",
ReadCode = el2.Element("ReadCode") != null
? el2.Element("ReadCode").Value
: "",
Rubric = el2.Element("Rubric") != null
? el2.Element("Rubric").Value
: "",
SubMicro = (from subMicroEl1 in xd.Descendants("Microbiology")
from subMicroEl2 in subMicroEl1.Descendants("Test")
orderby subMicroEl2.Element("Date").Value descending
orderby subMicroEl2.Element("Rubric").Value
where subMicroEl2.Element("Rubric").Value ==
el2.Element("Rubric").Value &&
subMicroEl2.Element("Date").Value !=
el2.Element("Date").Value
select new Microbiology
{
Date = subMicroEl2.Element("Date") != null
? subMicroEl2.Element("Date").Value
: "",
ReadCode = subMicroEl2.Element("ReadCode") != null
? subMicroEl2.Element("ReadCode").Value
: "",
Rubric = subMicroEl2.Element("Rubric") != null
? subMicroEl2.Element("Rubric").Value
: "",
}).ToList<Microbiology>()
});
XML:
<Microbiology>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value>123</Value>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value>123123</Value>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-10-23</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-30</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-30</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-30</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-30</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-07-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-05-12</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-05-12</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-05-12</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-05-12</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-03-07</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-03-07</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-03-07</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-03-07</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2008-01-15</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-11-07</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-11-07</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-11-07</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-11-07</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-10-08</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-08-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-08-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-06-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-06-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-06-13</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-06-13</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-05-04</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-05-04</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-05-04</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-05-04</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-01-26</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2007-01-26</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-09-29</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-09-29</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-31</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-31</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-31</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-31</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-16</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-16</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-16</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-08-16</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-06-02</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-06-02</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-06-02</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-06-02</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-05-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-05-09</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-05-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-05-09</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-01-17</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2006-01-17</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-11-22</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-11-22</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-10-18</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-10-18</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-10-18</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-10-18</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4JRA.</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus screening test</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-09-13</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-07-19</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-07-19</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-07-19</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-07-19</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-03-15</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-03-15</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-03-15</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-03-15</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J17.</ReadCode>
<Rubric>Sample culture</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2004-04-05</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2003-10-06</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2003-10-06</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2003-01-20</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2003-01-20</Date>
<ReadCode>4J15.</ReadCode>
<Rubric>Sample: organism sensitivity</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2002-06-17</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2002-06-17</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>1998-04-02</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2002-04-02</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2002-01-09</Date>
<ReadCode>4JG6.</ReadCode>
<Rubric>Skin swab culture positive</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-01-08</Date>
<ReadCode>4JG6.</ReadCode>
<Rubric>Skin swab culture positive</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2005-12-05</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-12-03</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-12-03</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-12-03</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-10-01</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-10-01</Date>
<ReadCode>4I16.</ReadCode>
<Rubric>Microscopy, culture and sensitivities</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-07-06</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-06-12</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-06-12</Date>
<ReadCode>4JG5.</ReadCode>
<Rubric>Skin swab culture negative</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2001-05-22</Date>
<ReadCode>4JG6.</ReadCode>
<Rubric>Skin swab culture positive</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2000-11-10</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2000-09-19</Date>
<ReadCode>4JG3.</ReadCode>
<Rubric>Skin ulcer swab taken</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2000-06-07</Date>
<ReadCode>4JP..</ReadCode>
<Rubric>Methicillin resistant staphylococcus aureus positive</Rubric>
<Value/>
<Units/>
</Test>
<Test>
<Date>2000-01-31</Date>
<ReadCode>4JG6.</ReadCode>
<Rubric>Skin swab culture positive</Rubric>
<Value/>
<Units/>
</Test>
</Microbiology>
I kind of understand what the code does, but I dont know how to modify it.
Update
What I need is to group them by Rubric or ReadCode and order them by date, even if dates are repeated I would just need one group and all elements inside with one with latest date situated at the top.
Any help would be appreciated.
Let me know if you need more info, I will keep checking the question.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可能误解了你的意思,但这就是你想要的吗?
希望能让你们更亲近
I might be misunderstanding you, but is this what you look for?
Hope that gets you closer
OR
OR
对于所有这三个代码片段,您可以简单地使用一个变量来列出您正在查找的 Rubric 或 ReadCode,它将返回包含所需代码的 Test 元素的列表。从那里您可以继续以最吸引您的方式对它们进行排序。希望这能有所帮助。
OR
OR
With all three of those code snippets you can simply use a variable to list which Rubric or ReadCode you are looking for and it will return a list of the Test elements that contain the needed codes. From there you can go ahead and sort them in whichever way best appeals to you. Hope this helped a little bit.
我认为您可能想做这样的事情:
我所做的如下: 1. 获取所有测试节点。 2. 按您想要的日期排序。 3. 通过 ReadCode 将它们分组,以便将它们分组。 4. 从分组结果中选择您的结果,并将 SubMicro 设置为剩余的元素列表(skip(1) 部分,如果您想要列表中的所有元素,请删除skip(1)。)。希望有帮助。
I think it might be something like this you want to do:
What I do is the following: 1. Take all tests node. 2. Order them by date since that what you want. 3. Group them byt ReadCode so you get them grouped. 4. Select your result from the grouped result, and set SubMicro to the remaining list of elements (the skip(1) part, remove skip(1) if you want all the elements in the list.). Hope it helps.