选择 <a> 的所有 href 属性的 XPath 查询标签,其中 'class' 属性等于指定的字符串 [英] XPath query to select all href attributes of &lt;a&gt; tag, which &#39;class&#39; attribute equals specified string

查看:17
本文介绍了选择 <a> 的所有 href 属性的 XPath 查询标签,其中 'class' 属性等于指定的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么以下查询不起作用:

I don't know why following query doesn't work:

//a/@href[@class='specified_string']

推荐答案

反过来试试:

//a[@class='specified_string']/@href

毕竟,class 元素的属性,而不是 href 属性的属性.

After all, class is an attribute of the <a> element, not an attribute of the href attribute.

这篇关于选择 <a> 的所有 href 属性的 XPath 查询标签,其中 'class' 属性等于指定的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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