Rookie Tutorial
Home
HTML
JavaScript
CSS
Vue
React
Python3
Java
C
C++
C#
AI
GO
SQL
Linux
VS Code
Bootstrap
Git
Local Bookmark
XSLT Tutorial
- XSLT Tutorial
- XSL Language
- XSLT Browser
- XSLT Transformation
- XSLT <template>
- XSLT <value-of>
- XSLT <for-each>
- XSLT <sort>
- XSLT <if>
- XSLT <choose>
- XSLT Apply
- XSLT Client
- XSLT Server
- XSLT Edit XML
- XML Editor
- XSLT Summary
- XSLT Examples
- XSLT Elements
- XSLT Functions
- XSLT Transformation Tool
- XSLT Examples
- XSLT Functions
- Deep Dive
- Web Browsers
- Programming
- Internet
- Development Tools
- Network Services
- Web Design and Development
- Programming Languages
- Computer Science
- Scripts
- Web Service
Advertisement
XSLT <xsl:for-each> Element
XSLT Element Reference Manual
Definition and Usage
The <xsl:for-each> element loops through each node in the specified node set.
Syntax
<xsl:for-each select="expression">
</xsl:for-each>
Attributes
| Attribute | Value | Description |
|---|---|---|
| select | expression | Required. An XPath expression that specifies the node set to be processed. |
Example
The following example loops through each <cd> element and writes each <cd> to the output:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<div>
<xsl:for-each select="catalog/cd">
<p><xsl:value-of select="title" /></p>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>
The following example loops through each <cd> element and creates a table to display the title and artist of each <cd>:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1>Music Collection:</h1>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<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>
XSLT Element Reference Manual
XSLT Examples
XSLT Functions
Byte Ark Coding Plan
Supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, official supply stable and reliable.
Β₯9.9 / month
iflytek Star Coding Plan
Includes free model call quota, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform.
Β₯3.9 / month
Category Navigation
- Python / Data Science
- AI / Intelligent Development
- Front-end Development
- Back-end Development
- Database
- Mobile Development
- DevOps / Engineering
- Programming Language
- Computer Fundamentals
- XML / Web Service
- .NET
- Website Construction
YouTip