I have a list of news items, sorted by dateCreated. I have a preview box control where I only want to show the first item. How can I do that using XSLT?
<xml>
<news>
<newsitem>
<dateCreated>2009-09-09</dateCreated>
<summary>Something great happened</sumamry>
</newsitem>
<newsitem>
<dateCreated>2009-09-08</dateCreated>
<summary>Something bad happened</sumamry>
</newsitem>
<newsitem>
<dateCreated>2009-09-07</dateCreated>
<summary>Something really bad happened</sumamry>
</newsitem>
</news>
</xml>
I had the same question and I think I found a better answer:
Selects the first book
newsItem
element, but note that IE5 and later has implemented that[0]
should be the first node, but according to the W3C standard it should be[1]
!If you wish to output XHTML 1.1, here's one way:
should do