Results 1 to 2 of 2

Thread: Max xml attribute .::RESOLVED::.

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2002
    Posts
    52

    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.

  2. #2

    Thread Starter
    Member
    Join Date
    Feb 2002
    Posts
    52
    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
  •  



Click Here to Expand Forum to Full Width