loading external div with php
<p>I was trying to load a page from H&amp;M (for studying purposes), when I noticed that the content of one div isn't loaded, but if I save the page from the browser, the div is saved correctly.
Can anyone explain me why this happens?<br>
The div (and most important, ist's contents) I'm looking for is:<br>
body><em>div</em> main><em>div</em> content> <em>div</em> <strong>relatedInformationContainer</strong><br>
(inside there's lot of content: <em>div</em> relatedInformation>etc...)<br>
this is the code i used:</p>

<pre><code>&lt;?php
$url = "http://www.hm.com/gb/product/05427";
libxml_use_internal_errors(true);
$html = file_get_contents($url);  
$dom = new DomDocument();  
$dom-&gt;loadHTML($html);  
$xp = new domxpath($dom);

$contentDivs = $xp-&gt;query('//div[@id="content"]')-&gt;item(0);
$numContentDivs = $xp-&gt;evaluate('count(div)', $contentDivs);
// echo $numContentDivs; // output:3 (correct)
$relatedDiv = $xp-&gt;query('//div[@id="content"]/div[2]')-&gt;item(0)-&gt;getAttribute("id");
echo $relatedDiv; // output:relatedInformationContainer (correct)
$relatedDivContent = $xp-&gt;query('//div[@id="content"]/div[2]')-&gt;item(0);
$numRelatedDivContent = $xp-&gt;evaluate('count(div)', $relatedDivContent);
echo $numRelatedDivContent; // output:0 (incorrect!!! it should output 1)
?&gt;
</code></pre>

<p>I used more simple methods, same result:</p>

<pre><code>&lt;?php
$url = "http://www.hm.com/gb/product/05427";
$doc = new DOMDocument();
$load = @$doc-&gt;loadHTMLFile($url);
echo $doc-&gt;saveHTML();
?&gt;
</code></pre>

<p>I would apreciate if anyone could explain me why this happens, and if there's a solution.
Thanks.</p>
