Latest web development tutorials

XSLT <xsl: sort> element

<Xsl: sort> element is used to output the results to be sorted.

Place where ordering information

To sort the output results, simply in the XSL file <xsl: for-each> element is added inside a <xsl: sort> element:


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"

<xsl:template match="/">
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<xsl:for-each select="catalog/cd">
<xsl:sort select="artist"/>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>


try it"

Note: selectattribute indicates the XML elements to be sorted.