|
-
Nov 12th, 2002, 03:55 AM
#1
Thread Starter
Member
Max xml attribute .::RESOLVED::.
Is there a way I can get the maximum value of a given attribute in an xml file using xpath?
Eg. if I wanted the max "id"
<root>
<subject>
<message id="2"/>
<message id="4"/>
<message id="8"/>
</subject>
<subject>
<message id="5"/>
</subject>
</root>
would return "8".
Thanks.
Last edited by Ashes; Nov 12th, 2002 at 05:54 AM.
-
Nov 12th, 2002, 05:53 AM
#2
Thread Starter
Member
Figured it out.
Here's the code for anyone who wants it....
<xsl:variable name="maxMessageID">
<xsl:for-each select="/root/subject/message">
<xsl:sort data-type="number" order="descending" select="@id"/>
<xsl:if test="position()=1">
<xsl:value-of select="@id"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|