XPath:逻辑或
请帮助使用 XPATH 中的逻辑 OR 运算符,并从这两个请求中选择一个:
1) .//span[@class=\'fob12\']
2) .//p [@class=\'fob12\']
它们仅在标签上有所不同。
Please help to use the logical OR operator in XPATH and select one request from these two:
1) .//span[@class=\'fob12\']
2) .//p[@class=\'fob12\']
They differ in tag only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
还有一个(按要求使用 OR):
One more (with the OR as requested):
您需要 联合表达式 ,即
|
,所以 XPath 将是:You want the union expression which is
|
, so the XPath would be:我可能会遗漏一些东西,但以下应该可以工作!?
I might be missing something, but the following should just work!?
我会将其写为
.//(p|span)[@class='fob12']
。但我认为这需要 XPath 2.0 IIRC。I would write it as
.//(p|span)[@class='fob12']
. But I think that needs XPath 2.0 IIRC.另一个 XPath:
Another XPath: