PHP xpath contains class and does not contain class
This should do it:
<?php
$doc = new DOMDocument();
$doc->loadHTMLFile('test.html');
$xpath = new DOMXPath($doc);
$nodeList = $xpath->query(
"//div[contains(@class, 'result') and not(contains(@class, 'grid'))]");
foreach ($nodeList as $node) {
echo $node->nodeName . "\n";
}
Your XPath would be //div[contains(concat(' ', @class, ' '), ' result ') and not(contains(concat(' ', @class, ' '), ' grid '))]