Skip to content
Thomas Weinert edited this page Jul 30, 2014 · 1 revision

FluentDOM\Query::not()

FluentDOM\Query not(string|callable $selector)

Removes elements matching the specified expression from the set of matched elements.

Usage

$html = <<<HTML
<html>
  <head>
    <title>Examples: FluentDOM\Query::not()</title>
  </head>
  <body>
    <div> </div>
    <div id="blueone"> </div>
    <div> </div>
    <div class="green"> </div>
    <div class="green"> </div>
    <div class="gray"> </div>
    <div> </div>
  </body>
</html>
HTML;

echo FluentDOM($html)
  ->find('//div')
  ->not('@class = "green" or @id = "blueone"')
  ->addClass('blue');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::not()</title>
  </head>
  <body>
    <div class="blue"> </div>
    <div id="blueone"> </div>
    <div class="blue"> </div>
    <div class="green"> </div>
    <div class="green"> </div>
    <div class="gray blue"> </div>
    <div class="blue"> </div>
  </body>
</html>
Clone this wiki locally