title: Javascript failure to generate divs that include XML info. (xml beginner)
body: <p>I am trying to create a script that will generate divs depending on the information of the XML file that I desire. The issue is that my script does not work at all. What I did was to find the code on w3schools.org and modified it a bit to match what I wanted it to do.</p>
  
  <p>The results:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  if (window.XMLHttpRequest)
  { // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
  }
  else
  { // code for IE6, IE5
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.open("GET","products.xml",false);
  xmlhttp.send();
  xmlDoc=xmlhttp.responseXML; 
  
  var size=0;
  var i=0;
  var x=xmlDoc.getElementsByTagName("honey");
  var y=x.length;
  var final=null;
  
  function gethoney()
  {
     for (i &lt; y) 
     { 
       a1='&lt;div style="height:200px;width:300px;float:left;background-color:#FFF5CC;opacity:0.7;text-align:center;"&gt;';
       a2='&lt;p&gt;&lt;b&gt;';
       a3=(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
       a4='&lt;br&gt;';
       a5=(x[i].getElementsByTagName("price")[0].childNodes[0].nodeValue);
       a6='&lt;/br&gt;&lt;/b&gt;&lt;/p&gt;';
       a8='&lt;/div&gt;';
       a9='&lt;div style="height:200px;width:20px;float:left;"&gt;&lt;/div&gt;';
       a10='&lt;div style="height:200px;width:100px;float:left;"&gt;';
       a11=(x[i].getElementsByTagName("image")[0].childNodes[0].nodeValue);
       a12='&lt;/div&gt;';
       final=final + a1 + a2 + a3 + a4 + a5 + a6 + a8 + a9 + a10 + a11 + a12;
       size=size+300;
       i=i+1;
     }
  document.getElementById("mainbody").style.height=size;
  size=size-20;
  document.getElementById("products").style.height=size;
  document.getElementById("products").innerHTML=final;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Using final in order to save every single div doesn't seem like an ideal way to me but I did it anyway.</p>
  
  <p>and the XML is this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1252"?&gt;
  &lt;honey&gt;
     &lt;name&gt;one&lt;/name&gt;
     &lt;price&gt;3&lt;/price&gt;
     &lt;image&gt;&lt;img src=""&gt;&lt;/img&gt;&lt;/image&gt;
     &lt;disc&gt;This is a honey&lt;/disc&gt;
  &lt;/honey&gt;
  &lt;honey&gt;
     &lt;name&gt;one&lt;/name&gt;
     &lt;price&gt;3&lt;/price&gt;
     &lt;image&gt;&lt;img src=""&gt;&lt;/img&gt;&lt;/image&gt;
     &lt;disc&gt;This is a honey&lt;/disc&gt;
  &lt;/honey&gt;
  etc etc
  </code></pre>
  
  <p>I tried to find info about this but without any luck. Could anyone point out what I am doing wrong and suggest improvements/corrections? Also, it would be appreciated if someone could write down a way to generate the divs without using <em>final</em> to save them and then innerHTML.</p>