title: How to get a div via PHP?
body: <p>I get a page using <code>file_get_contents</code> from a remote server, but I want to filter that page and get a DIV from it that has class "text" using PHP. I started with <code>DOMDocument</code> but I'm lost now. </p>
  
  <p>Any help?</p>
  
  <pre><code>$file = file_get_contents("xx");
  $elements = new DOMDocument();
  $elements-&gt;loadHTML($file);
  foreach ($elements as $element) {
      if( !is_null($element-&gt;attributes)) {
          foreach ($element-&gt;attributes as $attrName =&gt; $attrNode) {
              if( $attrName == "class" &amp;&amp; $attrNode== "text") {
                  echo $element;
              }
          }
      }
  }
  </code></pre>