在XPATH中使用OR的两个条件 [英] Two conditions using OR in XPATH

查看:956
本文介绍了在XPATH中使用OR的两个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框'txtSearch'。我用它来按姓氏搜索人。这是我的代码。

I have a textbox, 'txtSearch'. I am using it to search people by Last Name. this is my code.

var xmlTempResultSearch = xmlResidentListDisplay.selectNodes(
    "//PeopleList/Row[contains(translate(@LastName, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '" +
    txtSearch.value + "')]");

此代码选择XML中的所有姓氏,如txtSearch文本框中的文本输入。

This code selects all last names in the XML like the text input in the txtSearch textbox.

这会将所有大写字母转换为小写字母。

This translates all uppercase letters to lowercase letters.

因此,如果我正在搜索'Dorosan',如果我输入'doro',它会检索到正确的人,因为它将'D'翻译为'd'。但是当我输入'Doro'时,它并没有找到正确的人。

So if I am searching for 'Dorosan', if I type 'doro', it retrieves the correct person because it translated the 'D' to 'd'. But when I type 'Doro', it doesn't retrieve the correct person.

我想知道我是否可以在XPATH中有两个条件,以及如何?我希望能够将所有大写翻译为小写,或者将所有小写翻译为大写。

I'm wondering if I can have two conditions in an XPATH, and how? I want to be able to translate all uppercase to lowercase, OR translate all lowercase to uppercase.

推荐答案

您可以使用 / [....]

示例:

//*[contains('abc') or contains('def') or text()='abcdef']

更多有关运营商的信息:
http://www.w3schools.com/xpath/xpath_operators.asp

More info about operators: http://www.w3schools.com/xpath/xpath_operators.asp

这篇关于在XPATH中使用OR的两个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆