Thank you for the repsonse. But don't we have any xpath or xslt functions to acheive that.
Thanks,
KK
In XPath try this:
/root/node[not(@val <= preceding-sibling::node/@val) and not(@val <=following-sibling::node/@val)]
NOTE:If you find my response contains a reference to a third party World Wide Web site, I am providing this information as a convenience to you.Microsoft does not control these sites and has not tested any software or information found on these sites; therefore,Microsoft cannot make any representations regarding the quality,safety, or suitability of any software or information found there.
__________________________________________________
Sincerely,
Young Fang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Marked as answer by kalvagadda on May 14, 2007 03:19 PM
kalvagadda
Participant
1513 Points
281 Posts
xpath how to find node with max attribute value
May 10, 2007 09:19 PM|LINK
Hi guys
can any one tell what would be xpath to find node with max value of val attribute i.e. <node val="4" />
<root>
<node val="1"/>
<node val="2"/>
<node val="3"/>
<node val="4"/>
</root>
Thank you,
KK
xpath xslt
avidyarthi
Participant
1745 Points
372 Posts
Re: xpath how to find node with max attribute value
May 10, 2007 10:18 PM|LINK
Hey
you can try somethine like this:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(file);
XmlNodeList nodeList = xmlDoc.SelectNodes("root/node");
foreach (XmlNode xmlNode in nodeList)
{
string strName = xmlNode.Attributes["val"].Value;
int intStatsValue = Convert.ToInt32(xmlNode.InnerText);
//now you can store and compare the values
}
Hope this helps.
Please don't forget to "Mark as Answer" if this post answered your question.
kalvagadda
Participant
1513 Points
281 Posts
Re: xpath how to find node with max attribute value
May 10, 2007 10:24 PM|LINK
Thank you for the repsonse. But don't we have any xpath or xslt functions to acheive that.
Thanks,
KK
Young Fang -...
All-Star
17147 Points
1620 Posts
Re: xpath how to find node with max attribute value
May 14, 2007 04:40 AM|LINK
In XPath try this:
/root/node[not(@val <= preceding-sibling::node/@val) and not(@val <=following-sibling::node/@val)]
__________________________________________________
Sincerely,
Young Fang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
AshokRaja
Contributor
2674 Points
478 Posts
Re: xpath how to find node with max attribute value
May 14, 2007 09:14 AM|LINK
Have a look into this link. It uses a function math:max. It has a link for source for that function and explains how it can be implemented
http://www.exslt.org/math/functions/max/index.html
Hope this helps you
www.ashokraja.me
Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved.
kalvagadda
Participant
1513 Points
281 Posts
Re: xpath how to find node with max attribute value
May 14, 2007 03:24 PM|LINK
Hi,
Thanks for the reply. It was very helpful.
Thanks,
Kiran