xsl:for-each Element in XSLT
<xsl:for-each> Element :
Employees.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Employees>
<Employee>
<Name>Vijai</Name>
<Id>1</Id>
<Designation>Associate</Designation>
<Location>Bangalore</Location>
<Department>SharePoint</Department>
<Experience>3</Experience>
</Employee>
<Employee>
<Name>Ranjith</Name>
<Id>2</Id>
<Designation>Associate</Designation>
<Location>Bangalore</Location>
<Department>SharePoint</Department>
<Experience>5</Experience>
</Employee>
<Employee>
<Name>Rakesh</Name>
<Id>3</Id>
<Designation>Associate</Designation>
<Location>Chennai</Location>
<Department>LN</Department>
<Experience>6</Experience>
</Employee>
<Employee>
<Name>Kavya</Name>
<Id>4</Id>
<Designation>Associate</Designation>
<Location>Chennai</Location>
<Department>LN</Department>
<Experience>3</Experience>
</Employee>
<Employee>
<Name>Pai</Name>
<Id>5</Id>
<Designation>Associate</Designation>
<Location>Chennai</Location>
<Department>LN</Department>
<Experience>3</Experience>
</Employee>
</Employees>
EmployeesXSL.xsl:
<?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>
<h3 Style="font-weight:bold;
color:Green;font-style:italic">Employees</h3>
<table border="1">
<tr bgcolor="#CCCCFF">
<th>Name</th>
<th>Id</th>
<th>Department</th>
<th>Designation</th>
<th>Location</th>
<th>Experience</th>
</tr>
<xsl:for-each select="Employees/Employee">
<tr STYLE="font-weight:normal;
color:blue;font-style:italic">
<td>
<xsl:value-of select="Name"/>
</td>
<td>
<xsl:value-of select="Id"/>
</td>
<td>
<xsl:value-of select="Department"/>
</td>
<td>
<xsl:value-of select="Designation"/>
</td>
<td>
<xsl:value-of select="Location"/>
</td>
<td>
<xsl:value-of select="Experience"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output:
![output.jpg]()