change content of div with php DOMDocument
<p>I have html file, where I wont to replace only content of div width unique id , new content is html formated string.
I have code like this></p>

<pre><code>$file_contents = file_get_contents($html_file_to_replace);
    $doc-&gt;loadHTML($file_contents);
    $doc-&gt;formatOutput = false;
    $doc-&gt;strictErrorChecking = false;
    $el = $doc-&gt;getElementById('div_id');
    $str_replace  =  '&lt;span style="color:#e3effd;"&gt;this is a test&lt;/span&gt;';
    $el-&gt;nodeValue = $str_replace;
    $new_content = $doc-&gt;saveHTML();


    file_put_contents($html_file_to_replace,$new_content);
</code></pre>

<p>A.m. code replace content of div_id in file content with new content - </p>

<pre><code>&lt;span style="color:#e3effd;"&gt;this is a test&lt;/span&gt;
</code></pre>

<p>Problem is that if I display page in browser after replacement ($html_file_to_replace), new code in html file is not displayed as html formated string it is displayed as raw text including html marks. f.e.:</p>

<pre><code>&lt;span style="color:#e3effd;"&gt;asdf&lt;/span&gt;
</code></pre>

<p>Content which is not replaced is displayed correctly.  I tried also to convert string with mb_convert_encoding, html_entity_decode, but result is the same. </p>

<p>Many thanks for help. </p>
