2011-09-13 76 views
5

我願做一個負XPath查詢這樣的:如何否定xpath查詢?

$xpath->query(//a[DoesNotContain(@class,'some_class')]); 

我知道這個

$xpath->query(//a[contains(@class,'some_class')]); 
+0

的可能重複(HTTP [如何使用XPath的 「不」?] ://stackoverflow.com/questions/1550981/how-to-use-not-in-xpath) – kenorb

回答

10
$xpath->query(//a[not(contains(@class, 'some_class'))]); 
+0

// a [not [contains(@ class,'some_class')]]] – sam