search an XML node for a string

Discussion in 'XML' started by Thomas Patton, Aug 11, 2004.

  1. Hello

    I was wandering if anyone could help me with this problem, I have the
    following xsl file which searches the <description> node of my xml file.
    This node can contain text with more than one word and white space e.g.

    <catalog>
    <product>
    <item>shoes</item>
    <description>white trainers</description>
    </product>
    </catalog>

    At the moment, if I enter "white trainers" or "white trainers leather" in
    the textfield on my html file, the desired results are output by the xsl
    file.

    I was wandering what code I could use instead of or along with <xsl:if
    test="contains($text1, description)"> so that if I entered the following
    queries, the results would also be output by the xsl file:-

    white
    White
    trainers
    TRAINERS
    white green trainers

    and "trainer" if possible, but this query is not really as important as the
    others.

    <?xml version="1.0"?>

    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput method="html"/>

    <xsl:param name="text1" />

    <xsl:template match="/">

    <html>

    <head>
    <link rel="stylesheet" type="text/css" href="/web/files/mystyle.css" />
    <title>Results</title>
    </head>

    <body>

    <table width="600" border="1" align="center" cellpadding="0" cellspacing="0"
    bordercolor="#FFFFFF">

    <col width="100%" />

    <tr>

    <th class="fill">Item</th>

    </tr>

    <xsl:for-each select="catalog/product">
    <xsl:if test="contains($text1, description)">

    <tr>

    <td align="center"><xsl:apply-templates select="./item" /></td>

    </tr>

    </xsl:if>

    </xsl:for-each>

    </table>

    <div align="center">
    <a href="/web/index.html">Click here to return to search page</a>
    </div>

    </body>

    </html>

    </xsl:template>

    </xsl:stylesheet>



    I would be very greatful for any help on this.

    Thanks
    Thomas


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.721 / Virus Database: 477 - Release Date: 16/07/2004
     
    Thomas Patton, Aug 11, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,470
  2. Tjerk Wolterink
    Replies:
    2
    Views:
    1,440
    Dimitre Novatchev
    Aug 24, 2006
  3. Martin Honnen

    Re: Reading XML Node-by-Node

    Martin Honnen, Nov 12, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    389
    Martin Honnen
    Nov 12, 2008
  4. Geagleeye

    how to creating new node inside a xml node

    Geagleeye, Aug 2, 2006, in forum: ASP General
    Replies:
    2
    Views:
    199
    Geagleeye
    Aug 3, 2006
  5. Replies:
    0
    Views:
    140
Loading...

Share This Page