xml - XPath - extract value from parent with highest node value -
xml - XPath - extract value from parent with highest node value -
this xml snippet
<financialsummary> <summarydate format="yyyymmdd">20111231</summarydate> <revenue currency="eur">1249164523</revenue> </financialsummary> <financialsummary> <summarydate format="yyyymmdd">20101231</summarydate> <revenue currency="eur">1242344523</revenue> </financialsummary> <financialsummary> <summarydate format="yyyymmdd">20091231</summarydate> <revenue currency="eur">324900932</revenue> </financialsummary> im trying extract node content revenue node within financialsummary tag highest numeric summarydate value.
/financialsummary[summarydate = '20111231']/revenue this xpath returns right = 1249164523
max(/financialsummary/summarydate) this xpath returns right = 20111231
however when seek combine both nil returned
/financialsummary[summarydate = max(/financialsummary/summarydate)]/revenue is there missing? solution puzzle?
extra information: tried contains instead of '=' no luck that
i think look answers question :
financialsummary[summarydate = max(./parent::*/financialsummary/summarydate)]/revenue the context in predicate financialsummary. have in th tree others. look can homecoming several nodes, if have same date.
edit :
i remove first slash. consequence : have in right context (parent of financialsummary) launch xpath query.
xml xpath xsd xpath-2.0
Comments
Post a Comment