title: PHP DOMDocument how to get element?
body: <p>I am trying to read a website's content but i have a problem i want to get images, links these elements but i want to get elements them selves not the element content for instance i want to get that:  i want to get that entire element.</p>
  
  <p>How can i do this..</p>
  
  <pre><code>&lt;?php
  
      $ch = curl_init();
  
      curl_setopt($ch, CURLOPT_URL, "http://www.link.com");
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
      $output = curl_exec($ch);
  
      $dom = new DOMDocument;
      @$dom-&gt;loadHTML($output);
  
      $items = $dom-&gt;getElementsByTagName('a');
  
      for($i = 0; $i &lt; $items-&gt;length; $i++) {
          echo $items-&gt;item($i)-&gt;nodeValue . "&lt;br /&gt;";
      }
  
      curl_close($ch);;
  ?&gt;
  </code></pre>