我有以下XPATH选择。
//BLOCKQUOTE[@class='postcontent restore ']/A
现在我想使用通配符排除某些链接。
其中属性@href!="http://domain.com/download.php *'
我该怎么做?
//BLOCKQUOTE[@class='postcontent restore ']/A
现在我想使用通配符排除某些链接。
其中属性@href!="http://domain.com/download.php *'
我该怎么做?
用途:
//BLOCKQUOTE[@class='postcontent restore ']
/A[@href = 'http://domain.com/download.php']
这个选择器会选中XML文档中的任何A
元素,且该元素的href
属性值为'http://domain.com/download.php'
,并且是XML文档中的任何BLOCKQUOTE
元素的子元素,该元素的class
属性具有字符串值'postcontent restore '
如果你想要选中任何指向该域名的URL,请使用:
//BLOCKQUOTE[@class='postcontent restore ']
/A[starts-with(@href, 'http://domain.com/download.php')]
更新: 在评论中,OP澄清道:
用途:我想排除...任何以该链接/ URL开头的内容
//BLOCKQUOTE[@class='postcontent restore ']
/A[not(starts-with(@href, 'http://domain.com/download.php'))]