Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xpath to find max value in elements

Status
Not open for further replies.

leegold2

Technical User
Oct 10, 2004
116
given:
<links>

<l><a>1</a><n>Building</n></l>

<l><a>4</a><n>Community</n></l>
<l><a>2</a><n>Comedy</n></l>

<l><a>3</a><n>Computer</n></l>

</links>

What is an Xpath statement to find the maximum value in the "a" element node. It would be 4. I have searched and tried many examples with no luck. It must be simple? I could easily parse into an array and use an array's max function but would like to learn the xpath way.

Also I have been trying to determine if I have Xpath 1.0 or 2.0 and have searched to find what I have. In python and PHP how do I determine what version I have?

Many examples are extremely long and complicated and I have not found one that works. Help appreciated. I am using libxml2 in Python 2.6.

Is there a way to get Xpath 2.0 from command line in Linux if I don't have it?

Thanks,

Lee G.
 
I found it:

/links/l/a[not(. < /links/l/a)]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top