for-each << Output Filtering >> Data Sorting
Using XML and XSLT, this is really starting to look and feel like a database.

Wouldn't it be interesting if we could filter out a specific bunch of records depending on an equation? Modifying the for-each command, this is actually possible!

A filter can understand four basic equations...
=is equal to
!=is not equal to
<is less than
>is greater than

We will adjust the for-each command to filter out and display only the records showing ALL for the age_group values.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:template match="/">


<table border="1">
<xsl:for-each select="list_of_movies/movie[age_group='All']">
<td> <xsl:value-of select="title"/> </td>
<td> <xsl:value-of select="age_group"/> </td>
<td> <xsl:value-of select="comments"/> </td>



You can now view the XML page... XML Example 7

I know, it is a rather small example, but just imagine a huge list of movies are in there and only a few of them are labelled with the age_group value of All.

One very important thing to remember is that spelling, CaSe LeTtErInG, and spacing counts! To filter the results correctly, the parameter must match the values being looked at.
for-each << Output Filtering >> Data Sorting

Advertise in the banner along the top, Click here!

Valid XHTML 1.0 Transitional Valid CSS! Text Link Ads