简体   繁体   中英

Load malformed XML file into string javascript

I have a server response that is roughly of the form:

<A>...</A><B>...</B><C>...</C>

I am trying to load it using the code:

xhttp=new XMLHttpRequest();
xhttp.open("GET",dname,false);
xhttp.send("");

However I get the error

junk after document error

I plan on loading the malformed XML doc, and parsing out the info I need using regexes (i am not going to be parsing XML using regexes btw!!!)

How can I load this response as a string?

Changing the response from the server is not an option. And it must be in javascript.

Thanks

Well, assuming you know what you're doing

$.ajax({
  url: 'www.mydomain.com/generatexml',
  success: function(data) {
    console.log("XML received!", data);
    ...
    RegExp...
    ...
  }
}); 

(Using jQuery)

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