YouTip LogoYouTip

Xsl Sort

XSLT <xsl:sort> Element | Rookie Tutorial

XSLT <xsl:sort> Element

The <xsl:sort> element is used to sort the output results.

Where to Place Sort Information

To sort the output results, simply add an <xsl:sort> element inside the <xsl:for-each> element in the XSL file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:template match="/>
  <html>
  <body>
  <h2>My CD Collection</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Title</th>
      <th>Artist</th>
    </tr>
    <xsl:for-each select="catalog/cd">
      <xsl:sort select="artist"/>
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>
 
</xsl:stylesheet>

Try it yourself Β»

Note: The select attribute indicates the XML element to be sorted.

Related Tutorials

Coding Plans

Supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, etc., official supply is stable and reliable.

Β₯9.9 / month

Immediately activate

Starlight Coding Plan by iFlytek

Includes free model call quotas, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform.

Β₯3.9 / month

Immediately activate

Share your notes

Category Navigation

  • Python / Data Science
  • AI / Intelligent Development
  • Front-end Development
  • Back-end Development
  • Database
  • Mobile Development
  • DevOps / Engineering
  • Programming Languages
  • Computer Fundamentals
  • XML / Web Service
  • .NET
  • Website Construction

Advertisement

Explore in depth

  • Programming
  • Scripting Languages
  • Programming Languages
  • Network Design and Development
  • Scripts
  • Software
  • Computer Science
  • Web Service

XSLT Tutorial

  • XSLT Tutorial
  • XSL Language
  • XSLT Introduction
  • XSLT Browser
  • XSLT Transformation
  • XSLT Online Examples
  • Character Set & Tools
  • Latest Updates
  • Site Information

Follow WeChat

My Favorites

  • Mark Articles
  • Browsing History
  • Clear All
  • No Records Yet
← Xsl IfXsl Transformation β†’