Subject: Re: [xsl] search condition From: Peter Davis <pdavis152@xxxxxxxxx> Date: Wed, 6 Mar 2002 18:49:02 -0800 |
As others have pointed out, your method will work, but there is probably a better way of doing this: <xsl:key name="textid" match="root/children/textid" use="string(.)"/> <xsl:template ...> <xsl:for-each select="key('textid', 'ABC')"> <xsl:value-of select="."/> </xsl:for-each> </xsl:template> (the "root/children/textid" in the xsl:key could be shortened to just match "textid" unless you need to restrict the match to only textid's that are children of <children>'s and <root>'s) In general, xsl:key is much more efficient that using "//". On Wednesday 06 March 2002 02:04, Laura Jenkins wrote: > Dear people, > forgive me if my question is very basic. > > i want to search the element textid which has a text = 'ABC' > > can i acheive this by the for-each condition > > <xsl:for-each select="//root/children/textid[.='ABC']"> > > xml structure being > > <root> > <children> > <textid>ABC</textid> > </children> > <children> > <textid>DEF</textid> > </children> > <children> > <textid>ABC</textid> > </children> > <children> > <textid>FGH</textid> > </children> > <children> > <textid>ABC</textid> > </children> > </root> > > please correct me if i am wrong > i am writing the xsl like below > > <xsl:for-each select="//root/children/textid[.='ABC']"> > <!-- to print the text --> > <xsl:value-of select="."/> > </xsl:for-each> > > many thanks in advance > laura > > _________________________________________________________________ > Join the world?s largest e-mail service with MSN Hotmail. > http://www.hotmail.com > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list -- Peter Davis A Riverside, California, health ordinance states that two persons may not kiss each other without first wiping their lips with carbolized rosewater. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] search condition, Michael Kay | Thread | Re: [xsl] search condition, shenjun |
[xsl] word wrap in text string, ajay sinha | Date | Re: [xsl] XPath perfomance in attri, Peter Davis |
Month |