不同节点的 XPath OR 运算符 [英] XPath OR operator for different nodes

查看:17
本文介绍了不同节点的 XPath OR 运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用 XPath:

How can I do with XPath:

//bookstore/book/title or //bookstore/city/zipcode/title

只是 //title 不起作用,因为我还有 //bookstore/magazine/title

Just //title won't work because I also have //bookstore/magazine/title

附言我看到了很多或示例,但主要是属性或单节点结构.

p.s. I saw a lot of or examples but mainly with attributes or single node structure.

推荐答案

所有 title 节点以 zipcodebook 节点为父节点:

All title nodes with zipcode or book node as parent:

版本 1:

//title[parent::zipcode|parent::book]

版本 2:

//bookstore/book/title|//bookstore/city/zipcode/title

第 3 版:(结果根据源数据排序,而不是书本和邮政编码的顺序)

Version 3: (results are sorted based on source data rather than the order of book then zipcode)

//title[../../../*[book or magazine] or ../../../../*[city/zipcode]]

or - 在 true/false 中使用 - xpath 中的布尔运算符

or - used within true/false - a Boolean operator in xpath

| - xpath 中的联合运算符运算符右侧的查询附加到左侧查询的结果集.

| - a Union operator in xpath that appends the query to the right of the operator to the result set from the left query.

这篇关于不同节点的 XPath OR 运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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