Hi ....
This seems like it should be soooooo simple and obvious, but alas, I haven't been able to figure it out or find an answer on the web. I want to use an XPath expression to get the maximum attribute value from a set of nodes. For example, take this XML Document:
<MyList>
<Lists>
<Fruit FID="1" Title="one">
<FruitItem FIID="1" Text="apple" Sequence="1" />
</Fruit>
<Fruit FID="2" Title="two">
<FruitItem FIID="1" Text="pear" Sequence="1" />
<FruitItem FIID="2" Text="mango" Sequence="2" />
<FruitItem FIID="3" Text="grapes" Sequence="3" />
<FruitItem FIID="4" Text="pineapple" Sequence="4" />
<FruitItem FIID="5" Text="orange" Sequence="5" />
</Fruit>
<Lists>
</MyList>
I want to get the MAX Sequence attribute from the second Fruit node. I've been tryingThis works in XMLSpy, but I can't get it to work in VB.Net.Code:Dim xn As XmlNode = xDoc.SelectSingleNode("max(//Fruit[@FID=2]/FruitItem/@Sequence)")Is there anyway to get the Max Sequence value in one statement? Or will I have to loop over the nodes to get it?
Thanks!




Is there anyway to get the Max Sequence value in one statement? Or will I have to loop over the nodes to get it?
Reply With Quote