title: convert PHP DOMDocument to be readable as html tags.
body: <p>how do i convert elements that is created using DOMDocument to be readable as html?. if you run the code below the $appended will show the code like this = <a href="https://i.stack.imgur.com/8UHA7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8UHA7.png" alt="enter image description here"></a></p>
  
  <p>but what i am aiming is for it to be converted to html tags and to look like this. <a href="https://i.stack.imgur.com/dfWLZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dfWLZ.png" alt="enter image description here"></a></p>
  
  <pre><code>    &lt;?php
          global $connection;
          $html = "&lt;div id='suggested-video'&gt; 
          &lt;h2&gt;Suggestion For you&lt;/h2&gt;
          &lt;ul&gt;
  
          &lt;/ul&gt;
          &lt;/div&gt;";
          libxml_use_internal_errors(true);
          $doc = new DOMDocument(); 
          $doc-&gt;loadHTML($html);
  
          $sexy = 'sexy';
          $limit = 12;
          $isi = 1;
          $arrayz = array();
          $arrayz2 = array();
          $query = "SELECT `videoname`,`username`,`videourl`,`uploaddate`,`duration`,`views`,`tags`,`videoimage` FROM `videolist` WHERE `tags` = ? ";
          $stmt = $connection-&gt;prepare($query);
          $stmt-&gt;bind_param('s',$sexy);
          //$stmt-&gt;bindValue(":limitz",4,PDO::PARAM_INT);
          //$stmt-&gt;bindValue(":isi",1,PDO::PARAM_INT);
          $stmt-&gt;execute();
          $stmt-&gt;store_result();
          if($stmt-&gt;num_rows &gt; 0){
  
              $stmt-&gt;bind_result($videoname,$username,$videourl,$uploaddate,$duration,$views,$tags,$videoimage);
              while ($stmt-&gt;fetch()) {
                  $descBox = $doc-&gt;getElementById('suggested-video');
  
                  //create the element to append to #element1
                  $appended = $doc-&gt;createElement('li', "
                          &lt;a href='video.php?watch=$videourl'&gt;
                              &lt;li&gt;
                                  &lt;div class='leftside'&gt;
                                      &lt;img src='' width='100%' height='100%' style='background-color: blue;' &gt;                    
                                  &lt;/div&gt;
  
                                  &lt;div class='rightside'&gt;
                                      &lt;h4&gt;$videoname&lt;/h4&gt;
                                      &lt;p&gt;$username&lt;/p&gt;
                                      &lt;p&gt;$views views&lt;/p&gt;
                                      &lt;p&gt;$duration&lt;/p&gt;                    
                                  &lt;/div&gt;
  
                              &lt;/li&gt;
                          &lt;/a&gt;
  
                  ");
  
                  //actually append the element
                  $descBox-&gt;appendChild($appended);
  
              }
              echo $doc-&gt;saveHTML();
          }
      ?&gt;
  </code></pre>