XPath Help

Results 1 to 2 of 2

Thread: XPath Help

  1. #1
    Join Date
    Dec 1969

    Default XPath Help

    Say I have three nodes ... each with a 'lastid' attribute.. one has 5, another 10 and the last has 15 for it's value. Is there an Xpath expression that can select the one with 15? some sort of MAX() function or something?

  2. #2
    Join Date
    Dec 1969

    Default RE: XPath Help

    I&#039;m afraid I&#039;m too new to this to give you a definitive answer, but I did have a look round www.w3schools.com to try and help you. I think these pages will be of interest (they were to me).<BR><BR>http://www.w3schools.com/xsl/xsl_sort.asp<BR><BR>This URL is a page that tells you how to sort your xml nodes into an order depending on the value of a certain node or attribute. You could sort your nodes in order of your lastid attribute.<BR><BR>http://www.w3schools.com/xsl/xsl_functions.asp<BR><BR>This second URL has lots of nice functions that XSL can do. I think you need to use the count() function to find out the number of the last node in your (now sorted) list of XML nodes. The position() function gives you access to the node you are currently "looking" at.<BR><BR>My idea is to loop through your sorted list of nodes with an xsl:for-each thingy, and to use the xsl:if statement to display only the node where position() is equal to count().<BR><BR>I know this isn&#039;t a comprehensive answer but I thought some of those ideas might be able to help you. Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts