[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE:
Hi Brian, > I have an XML file with this structure: > > <elemA> > <elemB> > <elemC></elemC> > <elemC></elemC> > etc... > </elemB> > <elemB> > <elemC></elemC> > <elemC></elemC> > etc... > </elemB> > etc... > </elemA> > > I am writing an XSL file to search it. I want to be able to > search all of > the <elemC> nodes for the occurrence of a searchstring - and, > if an <elemC> > node matches the searchstring, to output the value of the > first <elemC> node > of the <elemB> node that contains the matching <elemC> node. > I hope that > makes sense! I haven't been able yet to get the XSL to > process each of the > <elemC> nodes of each of the <elemB> nodes systematically. To rephrase what you want a bit, you want to match/select all the <elemB> nodes which contain an <elemC> which itself contains the searchstring, and output the first <elemC> of that element. Try: <xsl:param name="string" select="'foo'"/> <xsl:for-each select="elemA/elemB[contains(elemC,$string)]"> <xsl:value-of select="elemC[1]"/> </xsl:for-each> Or similar. Cheers, Stuart XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|