title: Get element by tag name in php
body: <p>I'm trying to implement a search filter on a Laravel project. As I'm currently storing all the content of a page together through a WYSIWYG editor, the problem I'm facing now is how to get only the "p" tags on the content of the pages I retrieve from the database. I already tried a few things but nothing is working. Can anyone point me in the right direction? Here is what I'm trying so far:</p>
  
  <pre><code>&lt;div id="page-content" class="container"&gt;
  
    @foreach($searchResults as $searchResult) 
      &lt;div class="searchResult_div col-xs-12"&gt;
  
        &lt;div class="col-xs-9 col-sm-10 search-result-body"&gt;   
  
        &lt;?php
        $sr = HTML::decode($searchResult['body'], 450, "...");
        $dom = new DOMDocument();
        @$dom-&gt;loadHTML($sr);
        $sr_text = $dom-&gt;getElementsByTagName("p");
  
        echo $sr_text;
        ?&gt;
  
        &lt;/div&gt;
  
      &lt;/div&gt;
    @endforeach   
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Error: Object of class DOMNodeList could not be converted to string (View: /Users/ruirosa/Documents/AptanaStudio3Workspace/Marave4/app/views/search/search.blade.php)</p>