title: PHP DOM get items from first ul element
body: <p>I have html file which looks like this:</p>
  
  <pre><code>&lt;ul&gt;
   &lt;li&gt;item 1&lt;/li&gt;
   &lt;li&gt;item 2&lt;/li&gt;
   &lt;li&gt;item 3&lt;/li&gt;
  &lt;/ul&gt;
  &lt;ul&gt;
   &lt;li&gt;smth 1 2 3..&lt;/li&gt;
   &lt;li&gt;another&lt;/li&gt;
  &lt;ul&gt;
  &lt;ul&gt;
   &lt;li&gt;smth 1 2 3..&lt;/li&gt;
   &lt;li&gt;another&lt;/li&gt;
  &lt;ul&gt;
  </code></pre>
  
  <p>I am trying to get elements only from first ul list. I am using this code, but it returns errors:</p>
  
  <pre><code>&lt;?php
      $dom = new DOMDocument();
              $dom-&gt;loadHTML($data);
              $postalCodesList = $dom-&gt;getElementsByTagName('ul');
              foreach ($postalCodesList-&gt;item(0) as $postalCodesList) {
                   echo $postalCodesList-&gt;nodeValue.'&lt;br /&gt;';
  
              }
  ?&gt;
  </code></pre>