i have something like this
<ValueSet>
<value id="0">109.3</value>
<value id="1">110.6</value>
<value id="2">111.1</value>
<value id="3">111.5</value>
</ValueSet>
and i need the id of the node that has the maximum value, i need do this in javascript using Xpath.
i do this:
var path = "//ValueSet[not(value <= preceding-sibling::ValueSet/value) and " +
" not(value <= following-sibling::ValueSet/value)]";
var result = this.documentRoot.evaluate(path, this.documentRoot, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
alert("max:" + result.textContent);
but doesn't work, :(
Use:
/*/value[not(. < ../value)]/@id
Be ready to get more than one node, because there might be several nodes with the maximum value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With