title: Read XML contents and put into HTML page using JavaScript
body: <p>I need to read through the XML file that contains info but one at a time and display in an HTML page. It needs to appear like its scrolling on its own within the HTML inside a <code>&lt;div&gt;</code> and in form of <code>&lt;p&gt;</code>. Can some one help me out with how to do this?</p>
  
  <p>abc.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1" ?&gt;
  
  &lt;projects&gt;
  
  &lt;project&gt;
          &lt;flag&gt;1&lt;/flag&gt;
          &lt;name&gt;Project 1&lt;/name&gt;
          &lt;descp&gt; Short description. &lt;/descp&gt;
          &lt;rating&gt; 6 &lt;/rating&gt;
          &lt;link&gt; URL1 &lt;/link&gt;
          &lt;/project&gt;
  
  &lt;project&gt;
          &lt;flag&gt;1&lt;/flag&gt;
          &lt;name&gt;Project 2&lt;/name&gt;
          &lt;descp&gt; Short description. &lt;/descp&gt;
          &lt;rating&gt; 9 &lt;/rating&gt;
          &lt;link&gt; URL2 &lt;/link&gt;
          &lt;/project&gt;
  
  &lt;project&gt;
          &lt;flag&gt;1&lt;/flag&gt;
          &lt;name&gt;Project 3&lt;/name&gt;
          &lt;descp&gt; Short description. &lt;/descp&gt;
          &lt;rating&gt; 4 &lt;/rating&gt;
          &lt;link&gt; URL3 &lt;/link&gt;
          &lt;/project&gt;
  
  &lt;project&gt;
          &lt;flag&gt;1&lt;/flag&gt;
          &lt;name&gt;Project 4&lt;/name&gt;
          &lt;descp&gt; Short description. &lt;/descp&gt;
          &lt;rating&gt; 5 &lt;/rating&gt;
          &lt;link&gt; URL4 &lt;/link&gt;
          &lt;/project&gt;
  
  &lt;/projects&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  window.onload = timer;
  
  function timer() {
      var xmlDoc=new ActiveXObject("MSXML.DOMDocument");
      xmlDoc.async="false";
      xmlDoc.load("./gsss_hp.xml");
      var projects = xmlDoc.documentElement;
      var project = projects.childNodes(0);
      var numPro = projects.childNodes.length;   // to find number of projects entered in the file
  
      for(var i=0; i&lt;numPro; i++){
          for(var j=0; j&lt;100000;j++){j+=18; j-=18; for(var z=0;z&lt;5000;z++){}}  /* do noting for nested loops */
          show(i);
      }
  }
  
  function show(num) {
      var xmlDoc=new ActiveXObject("MSXML.DOMDocument");
      xmlDoc.async="false";
      xmlDoc.load("./gsss_hp.xml");
  
      var projects = xmlDoc.documentElement;
      var project = projects.childNodes(num);
      var attr = project.childNodes.length;
  
      for(var i=0;i&lt;attr;i++){
          var txt = xmlDoc.getElementsByTagName("project")[0].childNodes[i].nodeValue;
          txt = txt + "&lt;br /&gt;";
          var idPos;
          if(i==1) { idPos = "name"; }
          else
          if(i==2) { idPos = "descp"; }
          else
          if(i==3) { idPos = "rating"; }
          else
          if(i==4) { idPos = "link"; }
  
          document.getElementById(idPos).innerHTML = txt;
      }
  }
  
  &lt;/script&gt;
  </code></pre>