假設有XML:Groovy的GPATH受到許多條件的查找節點
<?xml version="1.0" encoding="UTF-8"?>
<data>
<level0 id="2" t="1">
<level1 id="lev1id21" att1="2015-05-12" val="121" status="0" year="2015" month="05" />
<level1 id="lev1id22" att1="2015-06-13" val="132" status="0" year="2015" month="06" />
<level1 id="lev1id23" att1="2015-07-11" val="113" status="0" year="2015" month="08" />
<level1 id="lev1id23" att1="2015-07-11" val="114" status="0" year="2015" month="07" />
</level0>
</data>
我要找到條件level1
節點(假設我們可以有很多level0
兄弟姐妹):
- 對於每個
level0
找到所有'level1'節點具有最大的att1
值(在yyyy-mm-dd中解釋爲Date
) - 在這些
level1
節點中找到一個具有最大v年份和月份的屬性,解釋爲int
s。
對於給定的例子,我期望找到具有val
=「113」值的節點。 由於我不是GPath的專家,請幫助找到正確的Groovish解決方案。謝謝。
您預期的結果不符合您的標準。你想按'att1',然後按'year',然後按'month'排序節點?在那種情況下,我希望給出你的數據的結果是'113'。 –
@thecodesmith_謝謝,我更新了預期結果,你說得對,我希望得到113 – lospejos