How to use like in XPath?

后端 未结 3 1646
轮回少年
轮回少年 2021-01-02 02:20

I have a page that searches with filters. I have this code for example,

xmlTempResultSearch = xmlResidentListDisplay.selectNodes(\"//PeopleList/Row[@LastName         


        
相关标签:
3条回答
  • 2021-01-02 02:41

    You can use start-with function and not function. Reference:

    http://www.w3schools.com/xpath/xpath_functions.asp

    xmlTempResultSearch = xmlResidentListDisplay.selectNodes("//PeopleList/Row[not(starts-with(@LastName,'"+ txtSearch.value +"'))]");
    
    0 讨论(0)
  • 2021-01-02 02:43

    you can use contains() function of XPath:

    xmlTempResultSearch = xmlResidentListDisplay.selectNodes("//PeopleList/Row[not(contains(@LastName,'"+txtSearch.value+"'))]");
    
    0 讨论(0)
  • 2021-01-02 03:00

    You can use all of the XPath (1.0) string functions. If you have XPath 2.0 available, then you can even use RegEx.

    contains()

    starts-with()

    substring()

    substring-before()

    substring-after()

    concat()

    translate()

    string-length()

    There is no **ends-with() in XPath 1.0, but it can easily be expressed with this XPath 1.0 expression**:

    substring($s, string-length($s) - string-length($t) +1) = $t
    

    is true() exactly when the string $s ends with the string $t.

    0 讨论(0)
提交回复
热议问题