title: PHP XPath check if empty
body: <p>I have this PHP code: </p>
  
  <pre><code>$document = new DOMDocument();
  $document-&gt;loadHTML( $html );
  
  $xpath = new DomXPath($document);
  
  $tables = $xpath-&gt;query("//*[contains(@class, 'info')]");
  $tableDom = new DomDocument();  
  $tableDom-&gt;appendChild($tableDom-&gt;importNode($tables-&gt;item(0), true));
  </code></pre>
  
  <p>How can I check if the $tables variable contains something that we can work with in the $tableDom? </p>
  
  <p>I tried it with:</p>
  
  <pre><code>if (!empty($tables)) {
      echo("&lt;/br&gt;not empty&lt;/br&gt;");
  } else {
      echo("empty");
  }
  
  if (!$tablese) {
      echo("empty&lt;/br&gt;");
  }
  </code></pre>
  
  <p>However it always said its not empty, all trough the HTML doesn't contain a table with the class info.</p>