title: How to write XML to DIV using innerHTML
body: <p>I would like to ask instead of using document.write, how do I write the XML info to a div using innerHTML? I tried to use document.getElementById("box").innerHTML but I am not sure how.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;script&gt;
      function loadXMLDoc(dname){
      if (window.XMLHttpRequest){
      xhttp=new XMLHttpRequest();
      }else{
      xhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      xhttp.open("GET",dname,false);
      xhttp.send();
      return xhttp.responseXML;
      }
  &lt;/script&gt;
  
  &lt;script&gt;
      xmlDoc=loadXMLDoc("books.xml");
  
      x=xmlDoc.getElementsByTagName("title");
      for (i=0;i&lt;x.length;i++)
      { 
      document.write(x[i].childNodes[0].nodeValue);
      document.write("&lt;br&gt;");
      //instead of using document.write how do I use innerHTML?
      //this is the method i tried:
      //txt = document.write(x[i].childNodes[0].nodeValue);
      //document.getElementById("box").innerHTML = txt;
      //it is not working, can anyone advice?
      }
      &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id="box"&gt;&lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>