Suppose having XML:
<?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>
I have to find level1
node by conditions (assuming we could have many level0
siblings):
- For each
level0
find all 'level1' nodes which have maximalatt1
value (interpreted asDate
in yyyy-mm-dd) - Among those
level1
nodes find one that has maximal value in year and month attributes, interpreted asint
s.
For given example, I expect node with val
="113" value to be found.
Since I'm not an expert in GPath, please help to find a correct and Groovish solution. Thanks.