title: Get DIV Element contents thru DOMDocument PHP
body: <p>I have to recover some news from a div of a site. The div is structured as follows:   </p>
  
  <p>The HTML Markup:</p>
  
  <pre><code>&lt;ul id="news-accordion" class="rounded" style="padding: 2px;"&gt;
     &lt;li class="o"&gt;
           &lt;h3&gt;
              &lt;span&gt;TITLE ARTICLE&lt;/span&gt;
              &lt;span&gt;30/10/2014&lt;/span&gt;
           &lt;/h3&gt;
           &lt;div style="display: none;"&gt;
                &lt;p&gt;text of article&lt;/p&gt;
           &lt;/div&gt;
     &lt;/li&gt;
     &lt;li class="e"&gt;
           &lt;h3&gt;
              &lt;span&gt;TITLE ARTICLE&lt;/span&gt;
              &lt;span&gt;28/10/2014&lt;/span&gt;
           &lt;/h3&gt;
           &lt;div style="display: none;"&gt;
                &lt;p&gt;text of article&lt;/p&gt;
           &lt;/div&gt;
     &lt;/li&gt;
     &lt;li class="o"&gt;
           &lt;h3&gt;
              &lt;span&gt;TITLE ARTICLE&lt;/span&gt;
              &lt;span&gt;29/10/2014&lt;/span&gt;
           &lt;/h3&gt;
           &lt;div style="display: none;"&gt;
                &lt;p&gt;text of article&lt;/p&gt;
           &lt;/div&gt;
     &lt;/li&gt;                                                     
  &lt;/ul&gt;
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>&lt;?php 
  
  $doc = new DomDocument;
  $doc-&gt;validateOnParse = true;
  $doc-&gt;loadHtml(file_get_contents('http://www.xxxxxxxxx/news.php'));
  
  $news = $doc-&gt;getElementById('news-accordion');
  
  $li = $news-&gt;getElementsByTagName('li'); 
  
  foreach ($li as $row){ 
  
      $title = $row-&gt;getElementsByTagName('h3'); 
      echo $title-&gt;item(0)-&gt;nodeValue."&lt;br&gt;&lt;br&gt;"; 
  
      /*foreach ($title as $row2){ 
      echo $row2-&gt;nodeValue."&lt;br&gt;&lt;br&gt;";
      //echo $row2-&gt;item(0)-&gt;nodeValue."&lt;br&gt;&lt;br&gt;"; 
      }*/
  
      $text = $row-&gt;getElementsByTagName('p'); 
      echo utf8_decode($text-&gt;item(0)-&gt;nodeValue)."&lt;br&gt;&lt;br&gt;&lt;br&gt;"; 
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>The code works correctly, but when I print the contents of the span tag <code>echo $title-&gt;item(0)-&gt;nodeValue;</code>, </p>
  
  <p>The text of the two span is printed together. </p>
  
  <p>How can I take the contents of the two span separately? Thanks.</p>