Skip to content
\n \n \n","url":"https://ez4code.com/snippets/xml-xslt","keywords":"xslt, transform, stylesheet","author":{"@type":"Person","name":"EZ4Code Team"},"publisher":{"@type":"Organization","name":"EZ4Code","logo":{"@type":"ImageObject","url":"https://ez4code.com/logo.png"}},"datePublished":"2024-01-01","dateModified":"2026-08-01","image":"https://ez4code.com/og-image.png"}
XML

XSLT

Transform XML into other formats.

By EZ4Code Team
xslttransformstylesheet

Code

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <body>
        <ul>
          <xsl:for-each select="catalog/book">
            <li>
              <xsl:value-of select="title"/> -
              <xsl:value-of select="author"/>
            </li>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Explanation

XSLT is a declarative, XML-based language that transforms a source XML document into XML, HTML, or text using template rules. Templates match nodes with XPath patterns and emit output, while xsl:for-each iterates over selections. Browsers and servers can apply XSLT either client-side or server-side.

More XML Snippets