Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(Hopefully) simple XSLT "filter" question:

Status
Not open for further replies.

MattWoberts

Programmer
Oct 12, 2001
156
GB
Hi,

I am new to XSLT stylesheets - and have what I hope may be a simple query :)

I have XML data of repeating items:
<Item>
<code>a</code>
<title>xxxx</title>
</item>
<Item>
<code>b</code>
<title>yyyy</title>
</item>

And I want to create an XSLT stylesheet to display each item in a table, BUT only if the &quot;code&quot; element of the &quot;item&quot; is set to &quot;a&quot; ... Please can someone help me out!!!

This is what I have so far that displays all &quot;items&quot; (cut down):

<xsl:template match=&quot;/Items&quot;>
<tr><td><xsl:value-of select=&quot;Title&quot;/></td></tr>
</xsl:template>

Many thanks!
Mattwoberts.

 

try this

<xsl:template match=&quot;/Items/code[text()='a']&quot;>
<tr><td><xsl:value-of select=&quot;Title&quot;/></td></tr>
</xsl:template>
 
Thanks! I take it that is saying &quot;filter on code where the text of code is equal to 'a'.....cool!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top