TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
xsl:for-each Element with filtering in XSLT
Vijai Anand Ramalingam
Apr 16, 2012
22.3
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog you will see an example for xsl:for-each Element with filtering in XSLT.
<xsl:for-each>
Element with filtering conditions:
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[Experience
>
3]
"
>
<
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:
Next Recommended Reading
select query on datatable for filter data