XmlNode xmlNode = xmlResponse.SelectSingleNode("//ITEM[fn:max(@NUMBER)]", nsmgr);
max() is an XPath 2.0..NET function that only supports XPath1.0.
In XPath 1.0 you can use:
Even if .NET implemented XPath 2.0, the XPath expression from the question does not select ITEM with a maximum attribute of NUMBER . The correct XPath 2.0 expression, using max() to select:
This is because the max() argument must be a sequence of elements in which we need to define the maximum element. Instead, in the XPath expression from the question:
//ITEM[fn:max(@NUMBER)]
max has only one argument - the NUMBER attribute of the node context. Therefore, the above is equivalent to:
//ITEM[@NUMBER]
which selects all ITEM elements that have the NUMBER attribute.
source share