How to check if element node contains a specific value in xsl

magnum

New Member
I have an XML file:\[code\]<?xml version="1.0" encoding="ISO-8859-1"?><document> <fruits> <fruit id="1"> <title>I like pineapples</title> <description> a tropical plant with edible multiple fruit consisting of coalesced berries</description> </fruit> <fruit id="2"> <title>I like watermelons</title> <description>has a smooth exterior rind (green, yellow and sometimes white) and a juicy, sweet interior flesh</description> </fruit> </fruits></document>\[/code\]How do I check if the title contains 'pineapple' so that i can only display description for that particular fruit.?Here is the XSL file I have:\[code\]<?xml version="1.0" encoding="iso-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:eek:utput method="xml" omit-xml-declaration="yes" doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.0//EN" doctype-system="http://www.wapforum.org/DTD/xhtml-mobile10.dtd"/> <xsl:template match="/"> <xsl:element name="html"> <xsl:element name="head"> <xsl:element name="title">Fruits</xsl:element> </xsl:element> <xsl:element name="body"> <xsl:if test="/document/fruits/fruit/title[contains(text(),'pineapple')]"> <xsl:value-of select="description"/> </xsl:if> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet>\[/code\]
 
Top