Tuesday, 11 October 2016

XML : xmlhttp.open multiple XML files

How would I go about fetching multiple XML files? I tried creating an array but that only opens the last file, and as I understand it xmlhttp.open is supposed to cancel any previous send. I tried modifying this which was the closest thing I could find, but my JavaScript knowledge is a bit to limited to adapt it.

This is the basic code I'm using to get one XML file.

  if (window.XMLHttpRequest)   { xmlhttp=new XMLHttpRequest();  }    xmlhttp.open("GET","myfile.xml",false);  xmlhttp.send();  xmlDoc=xmlhttp.responseXML;     var x=xmlDoc.getElementsByTagName("TAGNAME");  for (i=0;i<x.length;i++)  { // Further parsing  }    

Also is it possible to then display which file the parsed content comes from in my loop?

No comments:

Post a Comment