Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XPATH以使用通配符排除某些URL_Xpath_Wildcard - Fatal编程技术网

XPATH以使用通配符排除某些URL

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

我有以下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[@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开头的特定链接,因此从选择中排除。