How to filter what is shown in the for-each loop in XSL
Posted
by
Denoteone
on Stack Overflow
See other posts from Stack Overflow
or by Denoteone
Published on 2011-02-03T14:52:44Z
Indexed on
2011/02/03
15:26 UTC
Read the original article
Hit count: 246
I thought it would be as easy as tell the for-each to only select top_coach_sales_vw that has "Site" equal to "PB" but when I run the script it does not loop through any of the data in the XML.
I am escaping the single quotes because it is part of a php echo.
<xsl:for-each select="NewDataSet/top_coach_sales_vw[Site==\'PB\']">
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="Site"/></td>
<td><xsl:value-of select="Status"/></td>
</xsl:for-each>
XML:
<NewDataSet>
<top_coach_sales_vw>
<name>Mike</name>
<Site>PB</Site>
<State>Ready</State>
</top_coach_sales_vw>
<top_coach_sales_vw>
<name>Bill</name>
<Site>EL</Site>
<State>Talking</State>
</top_coach_sales_vw>
<top_coach_sales_vw>
<name>Ted</name>
<Site>PB</Site>
<State>Ready</State>
</top_coach_sales_vw>
</NewDataSet>
© Stack Overflow or respective owner