title: DOMDocument, grab several values on a website
body: <p>How can I get several values on a website using PHP (the value between div tags, value1, value2, value3 in the example below)?</p>
  
  <p>I have been looking into DOMDocument, but getting confused.</p>
  
  <p>Also, will it be possible to get the values without loading the website 3 times?</p>
  
  <p>Example.
  I need to get 3 values (or more) from a website:</p>
  
  <pre><code>&lt;div class="SomeUniqueClassName"&gt;value1&lt;/div&gt;
  &lt;div class="AnotherUniqueClassName"&gt;value2&lt;/div&gt;
  &lt;div class="UniqueClassName"&gt;value3&lt;/div&gt;
  </code></pre>
  
  <p>This is what I have now, but it looks stupid and i'm not 100% sure what i'm doing:</p>
  
  <pre><code>$doc = new DOMDocument;
  
  $doc-&gt;loadHTMLFile($url);
  
  $xpath = new DOMXPath($doc);
  
  $query1 = "//div[@class='SomeUniqueClassName']";
  $query2 = "//div[@class='AnotherUniqueClassName']";
  $query3 = "//div[@class='UniqueClassName']";
  
  $entry1 = $xpath-&gt;query($query1);
  $value 1 = var_dump($entry1-&gt;item(0)-&gt;textContent);
  
  $entry2 = $xpath-&gt;query($query2);
  $value 2 = var_dump($entry2-&gt;item(0)-&gt;textContent);
  
  $entry3 = $xpath-&gt;query($query3);
  $value 3 = var_dump($entry3-&gt;item(0)-&gt;textContent);
  </code></pre>