contains Function
Returns True if the first argument string contains the second argument string; otherwise returns False.boolean contains(string, string)
Res
If an argument is not of type string, it is first converted to a string and then evaluated.The following function call returns False.contains("mysampletest", "oba")

解决方案 »

  1.   

    对不起:net_lover(孟子E章)
    我看不太明白,请你写得仔细点好吗
      

  2.   

    在xsl用
    <xsl:if test="contains(nodeName, "xxx")">
    <xsl:value-of select="."/>
    </xsl:if>
      

  3.   

    我是第一次用到xlst 对他不是很老解。你说的xxx是输入的查询字符串,可是怎么从页面传到xlst里呀
      

  4.   

    如果你对xsl不是很熟悉,可以用XmlDocument的SelectNodes()方法进行比较直观addParameter Method
    Adds parameters into an Extensible Stylesheet Language Transformations (XSLT) style sheet.
    var xslt = new ActiveXObject("Msxml2.XSLTemplate");
    var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
    var xslProc;
    xslDoc.async = false;
    xslDoc.resolveExternals = false;
    xslDoc.load("sample.xsl");
    xslt.stylesheet = xslDoc;
    var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
    xmlDoc.async = false;
    xmlDoc.resolveExternals = false;
    xmlDoc.load("books.xml");
    xslProc = xslt.createProcessor();
    xslProc.input = xmlDoc;
    xslProc.addParameter("param1", "Hello");
    xslProc.transform();
    alert(xslProc.output);
    Sample.xsl<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       <xsl:output method="html"/>
       <xsl:param name="param1"/>
      <xsl:template match="/">
          The parameter value was: <xsl:value-of select="$param1"/>
      </xsl:template>
    </xsl:stylesheet>
      

  5.   

    我用的是C# 
    你写的var等代码是不是写到页面上呀,不用写入到后台,对吗?
      

  6.   

    System.Xml.XmlDocument x = new System.Xml.XmlDocument();
    x.Load(Server.MapPath("x1.xml"));
    System.Xml.XmlNodeList nodes = x.SelectNodes("//Name");
    foreach(System.Xml.XmlNode y in nodes)
    {
    if(y.InnerText.IndexOf("李") >-1)
    Response.Write(y.InnerText);
    }x1.xml
    ========
    <?xml version="1.0" encoding="GB2312"?>
    <Persons>
    <Person id="1">
    <Name>李一</Name>
    <Sex>男</Sex>
    </Person>
    <Person id="2">
    <Name>李二</Name>
    <Sex>女</Sex>
    </Person>
    <Person id="3">
    <Name>李三</Name>
    <Sex>男</Sex>
    </Person>
    <Person id="4">
    <Name>陈四</Name>
    <Sex>男</Sex>
    </Person>
    <Person id="5">
    <Name>李四</Name>
    <Sex>女</Sex>
    </Person>
    </Persons>