XPath 谓词中的“OR"运算符? [英] 'OR' operator in XPath predicate?
本文介绍了XPath 谓词中的“OR"运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
选择XPath表达式是什么> 带有
type="application/rss+xml"
的元素 OR type="application/atom+xml"
(RSS 和 Atom 提要)
What is the XPath expression to select <link>
elements with type="application/rss+xml"
OR type="application/atom+xml"
(RSS and Atom feeds)
link[@rel='alternate'][@type='application/rss+xml']
选择 RSS 提要link[@rel='alternate'][@type='application/atom+xml']
选择 Atom 提要
link[@rel='alternate'][@type='application/rss+xml']
selects RSS feedslink[@rel='alternate'][@type='application/atom+xml']
selects Atom feeds
但是选择它们的单个 XPath 表达式是什么?
But what is the single XPath expression for selecting them both?
谢谢.
推荐答案
use:
link[@rel='alternate'][@type='application/rss+xml' or @type='application/atom+xml']
见 http://www.w3.org/TR/xpath/#NT-OrExpr
您也可以使用 union 来完成此操作
You could also use union to accomplish this
link[@rel='alternate'][@type='application/rss+xml']|link[@rel='alternate'][@type='application/atom+xml']
但是或
可以.
这篇关于XPath 谓词中的“OR"运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文