我不知道为什么以下查询不起作用:
//a/@href[@class='specified_string']
Run Code Online (Sandbox Code Playgroud)
ndi*_*dim 48
反过来试试:
//a[@class='specified_string']/@href
Run Code Online (Sandbox Code Playgroud)
毕竟,class
是<a>
元素的属性,而不是属性的href
属性.
属性不能包含属性.只有元素才能拥有属性.
原始的XPath表达式:
//a/@href[@class='specified_string']
Run Code Online (Sandbox Code Playgroud)
选择任何元素的任何href
属性a
,以使该href
属性具有class
值为的属性'specified_string'
.
你想要的是:
//a[@class='specified_string']/@href
Run Code Online (Sandbox Code Playgroud)
即:具有值的href
属性的任何a
元素的属性.class
'specified_string'
归档时间: |
|
查看次数: |
75929 次 |
最近记录: |