title: Extract content of specific div class php dom
body: <p>Hi there i want to extract a specific div class only from a specific website.</p>
  
  <p>Here is what i have but it doesn't work for some reason, I get loads of errors::</p>
  
  <pre><code>$page = file_get_contents('https://extcall.17track.net/en/track#apitype=1&amp;nums=RK444760227FR');
  $doc = new DOMDocument();
  $doc-&gt;loadHTML($page);
  $divs = $doc-&gt;getElementsByTagName('div');
  foreach($divs as $div) {
      // Loop through the DIVs looking for one withan id of "content"
      // Then echo out its contents (pardon the pun)
      if ($div-&gt;getAttribute('class') === 'tracklist-fill') {
           echo $div-&gt;nodeValue;
      }
  }
  </code></pre>
  
  <p>what i want to extract is the tracking results only without the brand or title or other elements</p>
  
  <p>what am i doing wrong ?</p>
  
  <p>cheers</p>
  
  <p>these are the errors im getting</p>
  
  <pre><code>Warning: DOMDocument::loadHTML(): Tag main invalid in Entity, line: 1 in /volume1/web/track/test3.php on line 7
  Warning: DOMDocument::loadHTML(): Tag section invalid in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Tag section invalid in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : p in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : p in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7 
  Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 1 in /volume1/web/track/test3.php on line 7
  </code></pre>
  
  <p>and this is the html snippet from the website you see above in file get contents</p>
  
  <p>body > main > div > section.yq-panel.yq-panel-tracklist.jcTrackContainer > div > div.tracklist-fill</p>
  
  <pre><code>&lt;div class="tracklist-fill"&gt;
      &lt;div class="tracklist-ps-transit"&gt;
          &lt;div class="yqcr-ps" data-ps="10"&gt;&lt;a class="btn btn-icon fa-PS_10 ps-bgcolor-10 waves-effect" title="In transit"
                                               href="//help.17track.net/hc/en-us/articles/228084227#10"
                                               yqg-events="{C:功能操作,A:结果页-查看帮助,L:包裹状态_10}" target="_blank"
                                               data-icon=""&gt;&lt;/a&gt;
              &lt;div data-name=""&gt;&lt;p class="text-uppercase" title="RK444760227FR"&gt;RK444760227FR&lt;/p&gt;
                  &lt;p class="text-capitalize" title="In transit"&gt;In transit&lt;/p&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="yqcr-transit"&gt;
              &lt;div class="from" data-key="06051"&gt;
                  &lt;div class="base-info" data-carrier-type="fc"&gt;
                      &lt;div&gt;&lt;span title="France" data-country=""&gt;France&lt;/span&gt; &lt;i title="La Poste"&gt;La Poste&lt;/i&gt;&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="action-info"&gt;&lt;a class="btn btn-icon btn-pure btn-default fa-home waves-effect waves-circle"
                                              target="_blank" href="http://www.laposte.fr/"
                                              yqg-events="{C:功能操作,A:结果页-跳转运输商官网,L:06051}"
                                              title="Go to the carrier's official website."&gt; &lt;/a&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="to" data-key="07071"&gt;
                  &lt;div class="base-info" data-carrier-type="sc"&gt;
                      &lt;div&gt;&lt;span title="Greece" data-country=""&gt;Greece&lt;/span&gt; &lt;i title="ELTA"&gt;ELTA&lt;/i&gt;&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="action-info"&gt;&lt;a class="btn btn-icon btn-pure btn-default fa-home waves-effect waves-circle"
                                              target="_blank" href="http://www.elta.gr/"
                                              yqg-events="{C:功能操作,A:结果页-跳转运输商官网,L:07071}"
                                              title="Go to the carrier's official website."&gt; &lt;/a&gt;&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="tracklist-events scrollable is-enabled scrollable-vertical" yq-data="scrollBox"
           style="position: relative;"&gt;
          &lt;div class="scrollable-container" style="height: 360px; width: 909px;"&gt;
              &lt;div class="scrollable-content" style="width: 892px;"&gt;
                  &lt;div class="hide"&gt;&lt;p data-newevents=""&gt;FRANCE, DEPARTURE FROM OUTWARD OFFICE OF EXCHANGE&lt;/p&gt;
                      &lt;time data-newtime=""&gt;2018-12-11 07:15&lt;/time&gt;
                  &lt;/div&gt;
                  &lt;div class="yqcr-details"&gt;
                      &lt;dl class="des-block" data-from="en"&gt;
                          &lt;dt&gt;&lt;span&gt;Destination&lt;/span&gt; &lt;span&gt;: Greece&lt;/span&gt; &lt;span&gt;- Tracking consuming: 958 ms&lt;/span&gt;
                          &lt;/dt&gt;
                          &lt;dd class="new"&gt;&lt;i&gt;&lt;/i&gt;
                              &lt;div&gt;
                                  &lt;time&gt;2018-12-11 07:15&lt;/time&gt;
                                  &lt;p&gt;FRANCE, DEPARTURE FROM OUTWARD OFFICE OF EXCHANGE&lt;/p&gt;&lt;/div&gt;
                          &lt;/dd&gt;
                          &lt;dd class=""&gt;&lt;i&gt;&lt;/i&gt;
                              &lt;div&gt;
                                  &lt;time&gt;2018-12-08 09:07&lt;/time&gt;
                                  &lt;p&gt;FRANCE, POSTING/COLLECTION&lt;/p&gt;&lt;/div&gt;
                          &lt;/dd&gt;
                      &lt;/dl&gt;
                      &lt;dl class="ori-block" data-from="fr"&gt;
                          &lt;dt&gt;&lt;span&gt;Origin&lt;/span&gt; &lt;span&gt;: France&lt;/span&gt; &lt;span&gt;- Tracking consuming: 1452 ms&lt;/span&gt;&lt;/dt&gt;
                          &lt;dd class=""&gt;&lt;i&gt;&lt;/i&gt;
                              &lt;div&gt;
                                  &lt;time&gt;2018-12-08 00:00&lt;/time&gt;
                                  &lt;p&gt;CHAMPAGNOLE, Pris en charge&lt;/p&gt;&lt;/div&gt;
                          &lt;/dd&gt;
                      &lt;/dl&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="scrollable-bar scrollable-bar-vertical is-disabled scrollable-bar-hide" draggable="false"&gt;
              &lt;div class="scrollable-bar-handle"&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and these are the elements i want in the picture</p>
  
  <p><a href="https://imgur.com/ajblnNV" rel="nofollow noreferrer">https://imgur.com/ajblnNV</a></p>