XPATH以使用通配符排除某些URL
我有以下XPATH选择 //BLOCKQUOTE[@class='postcontent restore']/A 现在我想使用通配符排除某些链接 Where attribute@href="http://domain.com/download.php *" 我该怎么做?使用:XPATH以使用通配符排除某些URL,xpath,wildcard,Xpath,Wildcard,我有以下XPATH选择 //BLOCKQUOTE[@class='postcontent restore']/A 现在我想使用通配符排除某些链接 Where attribute@href="http://domain.com/download.php *" 我该怎么做?使用: //BLOCKQUOTE[@class='postcontent restore '] /A[@href = 'http://domain.com/download.php'] //BLOCKQUOTE[@c
//BLOCKQUOTE[@class='postcontent restore ']
/A[@href = 'http://domain.com/download.php']
//BLOCKQUOTE[@class='postcontent restore ']
/A[not(starts-with(@href, 'http://domain.com/download.php'))]
这将选择XML文档中的任何元素,其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[@href = 'http://domain.com/download.php']
//BLOCKQUOTE[@class='postcontent restore ']
/A[not(starts-with(@href, 'http://domain.com/download.php'))]
感谢您的回复…我想排除…任何以该链接/url开头的内容…我尝试了以下运算符!=但它仅适用于我想使用通配符排除以-5-等url开头的特定链接,因此从选择中排除。