如何编写 XPath 查询来匹配两个属性? [英] How to write an XPath query to match two attributes?

查看:27
本文介绍了如何编写 XPath 查询来匹配两个属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下问题:

以上,

如果我想要一个同时检查 id 和 class 的 XPath 表达式,我们可以用and"条件 LIKE 来做:

//div[@id='id-74385'] 和 div[@class='guest clearfix']

这是正确的方法吗?我在这里执行失败...请帮忙!

解决方案

//div[@id='..' and @class='...]

应该可以解决问题.这就是选择具有both 所需值属性的div 运算符.

值得使用 在线 XPath 测试平台之一来尝试一下出来.

Following Question:

<div id="id-74385" class="guest clearfix" style="z-index: 999;">

Given above,

If I want a XPath expression with checks both id and class, can we do it w/ 'and' condition LIKE:

//div[@id='id-74385'] and div[@class='guest clearfix']

Is this correct way? My execution fails here... Please help!

解决方案

//div[@id='..' and @class='...]

should do the trick. That's selecting the div operators that have both attributes of the required value.

It's worth using one of the online XPath testbeds to try stuff out.

这篇关于如何编写 XPath 查询来匹配两个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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