Skip to content
Advertisement

Obtaining min/max values of an element with xpath

I have an xml sheet like:

JavaScript

I am obtaining the weight of the devices using simplexml and xpath like so:

JavaScript

I am trying to figure out how I can obtain the min and max values of the weight element. I have looked at many solutions regarding xpath but most cover attribute values and are not applicable to a sheet formatted like this. Any help would be appreciated!

Advertisement

Answer

You can map all the values to an array then use max and min functions:

JavaScript

Output:

Min: 3.00

Max: 3.34

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement