![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Is this the best way to operate on a specific data item? [Thread Next] Re: Is this the best way to operate on a specific data item?To: NULL Date: 8/20/2008 3:33:00 PM Brian Kendig wrote: > I have an XML file containing news items, each of which has a date > associated with it. I want to display only the news item with the most > recent date. > > This is the approach I'm using: > > <xsl:for-each select="//newsItem"> > <xsl:sort select="date" order="descending"/> Make sure the date element has content in a sortable format like YYYY-MM-DD or YYYYMMDD. > <xsl:if test="position() = 1"> > ... > </xsl:if> > </xsl:for-each> > > Is there a more sophisticated solution? With XSLT 2.0 you can also use the max function e.g. <xsl:value-of select="max(date)"/> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
