Heb*_*dly 7 xml xpath xpath-1.0
XPath 1.0中是否有一个运算符在SQL中充当"in"运算符?
select * from tbl_students where id in (1,2,3)
Run Code Online (Sandbox Code Playgroud)
C. *_*een 15
XPath 1.0的=运算符以这种方式工作,尽管XPath 1.0不提供编写序列的语法.因此,如果您有表单的XML文档
<doc>
<value>1</value>
<value>2</value>
<value>3</value>
</doc>
Run Code Online (Sandbox Code Playgroud)
然后表达式//doc[value = 2]将返回该doc元素.
在XPath 2.0中,语法(1, 2, 3)将创建一个包含三个整数的序列,您可以编写类似的条件$i = (1, 2, 3).但是文字序列不是XPath 1.0的一个特性 - 在XPath表达式的一侧获取多个值的唯一方法是使用匹配多个节点的路径表达式.
我有同样的问题,上面的答案是对的.为了更清楚,在Xpath中,这将看起来像:
//*:document[*:documentType=("magazine","newspaper")]
Run Code Online (Sandbox Code Playgroud)
这将是以下的等价物:
select * from documents where documenttype in ('newsletter','magazine')
Run Code Online (Sandbox Code Playgroud)