title: Using javascript to display XML data in HTML
body: <p>Hi currently I have the following XML file and my script.</p>
  
  <pre><code>&lt;ResourcesList&gt;
      &lt;ResourceGroup type = "HUMANS"&gt;
          &lt;ResourcesInfo JobPosition = "Station Manager"          OnDuty  = "40"  OnLeave_Local = "1" OnLeave_Oversea = "1"   MC = "2" /&gt;
          &lt;ResourcesInfo JobPosition = "Deputy Station Manager"   OnDuty  = "82"  OnLeave_Local = "5" OnLeave_Oversea = "5"   MC = "2" /&gt;
          &lt;/ResourceGroup&gt;
         &lt;ResourceGroup type = "MACHINES"&gt;
          &lt;ResourcesInfo MachineName = "Leopard 2SG"      MachineID = "SB1420J"   MachineType = "Battle Tank"     Available = "15" NotAvailable = "2"  /&gt;
          &lt;ResourcesInfo MachineName = "M113A2 ULTRA OWS" MachineID = "SS4020J"   MachineType = "Transport Vechicle" Available = "50" NotAvailable = "21" /&gt;
      &lt;/ResourceGroup&gt;
  &lt;/ResourcesList&gt;    
  
  &lt;script&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","ResourceList.xml",false);
  xmlhttp.send();
  xmlDoc=xmlhttp.responseXML; 
  
  document.write("&lt;table border='1'&gt;");
  
  var x=xmlDoc.getElementsByTagName("ResourceGroup");
  for (i=0;i&lt;x.length;i++)
    { 
    document.write("&lt;tr&gt;&lt;td&gt;");
    document.write(x[i].getElementsByTagName("ResourcesInfo")[0].childNodes[0].nodeValue);
    }
  document.write("&lt;/table&gt;");
  &lt;/script&gt;
  </code></pre>
  
  <p>Anybody can help?? I followed the example in w3school and tried writing it out but it tells me the following error.</p>
  
  <p><strong>TypeError:</strong> <code>x[i].getElementsByTagName(ResourcesInfo)[0].childNodes[0] is undefined.</code></p>