tags:

views:

141

answers:

1

I have a structure like this:

  <Info ID="1">
    ...
    <Date>2009-04-21</Date>
  </Info>
  <Info ID="2">
 ...
    <Date>2009-04-22</Date>
  </Info>
  <Info ID="3">
 ...
    <Date>2009-04-20</Date>
  </Info>

I want to get the latest date using XSLT (in this example - 2009-04-22).

+3  A: 

Figured it out, wasn't as hard as I thought it will be:

        <xsl:variable name="latest">
          <xsl:for-each select="Info">
            <xsl:sort select="Date" order="descending" />
            <xsl:if test="position() = 1">
              <xsl:value-of select="Date"/>
            </xsl:if>
          </xsl:for-each>
        </xsl:variable>
      <xsl:value-of select="$latest"/>
Mindaugas Mozūras