简体   繁体   中英

“GET” multiple xml file in html

I am trying to show multiple xml file into html. I able get single xml file show in html table by using xmlhttp.open("GET", "204S_2000_02_17_00_30_357.xml", true) . However, I can't get multiple xml file using this function.

I had tried using xmlhttp.open("GET", "*.xml", true) but doesn't get any output.

It's any solution or method to "GET" the multiple xml file into html?

Noted: xml file will continuously generate in folder with random name.(example 204S_2000_02_XX_XX_XX_XX.xml).

code that show single xml file in html table

function loadXMLDoc() {
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      myFunction(this);
    }
  };
  xmlhttp.open("GET", "204S_2000_02_17_00_30_357.xml", true);
  xmlhttp.send();
}

function myFunction(xml) {
//coding....
}

One HTTP request gets one HTTP response.

In general , you can't get multiple files back from a single request using a wildcard.

You could, if you wrote suitable server-side code , have the server recognise a wildcard in the URL and respond by (for example) sending a zip file containing all the files that matched, or generating a new XML document containing the contents of all the files that matched.

Generally, however, you will make a separate request for each resource you want. Having determined all the URLs you wanted to request, you would probably want to use an API that supported promises (ie fetch instead of XMLHttpRequest ) so you could feed them into Promise.all and run the next stage of the program once you had collected all the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM