【发布时间】:2010-04-22 14:35:58
【问题描述】:
我不知道为什么以下查询不起作用:
//a/@href[@class='specified_string']
【问题讨论】:
-
由于类属性可能包含多个用空格分隔的类名,您可能实际上想要:
//a[contains(concat(' ',normalize-space(@class),' '), 'some_class_name')]/@href -
@singpolyma:好点。只是一个挑剔:它是
' some_class_name '(周围有空格),不是'some_class_name'。
标签: xpath