Friday, 22 June 2007

top id from xml


Clever little XPath 1.0, gets the node with the highest id value. Xpath 2.0 has the max() function that ultimately does the same thing.

/rt/item[@id[not(. < ../../item/@id)]]


<rt>
<item id="1">txt</item>
<item id="2">txt</item>
<item id="5">txt</item>
<item id="4">txt</item>
</rt>


returns

<item id="5">txt</item>

No comments: