title: PHP DOM previousSibling doesn't work
body: <pre><code>&lt;?php
  
  $dom = new \domDocument;
  $dom-&gt;loadHTML('&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
     &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
     &lt;/head&gt;
     &lt;body&gt;
         &lt;div&gt;
          &lt;h1&gt;Title1&lt;/h1&gt;
          &lt;p&gt;&lt;img src="" /&gt;&lt;/p&gt;
          &lt;h1&gt;Title2&lt;/h1&gt;
          &lt;p&gt;&lt;img src="" /&gt;&lt;/p&gt;
          &lt;h1&gt;Title3&lt;/h1&gt;
          &lt;p&gt;&lt;img src="" /&gt;&lt;/p&gt;
          &lt;h1&gt;Title4&lt;/h1&gt;
          &lt;p&gt;&lt;img src="" /&gt;&lt;/p&gt;
          &lt;p&gt;&lt;img src="" /&gt;&lt;/p&gt;
         &lt;/div&gt;
     &lt;/body&gt;
  &lt;/html&gt;');
  
          $xpath = new \DOMXPath($dom);
          $nodelist = $xpath-&gt;query('//div/p/img');
          foreach($nodelist as $k=&gt;$v){
              $title1 = $v-&gt;parentNode-&gt;previousSibling-&gt;textContent;
          }
  </code></pre>
  
  <p>I want to retrieve every text inside h1 tag, but previousSibling attribute seems to be not working, it returns a node without tagname attribute and its previousSibling attribute is "(object value omitted)"</p>
  
  <p>My path must be followed as img->p->previous h1 , since not every p tag has its own h1 tag in my case.</p>
  
  <p>Thank you !</p>