The browser is not reading the xml file because of ampersands like "&". I'd like to get the xml file and replace all "&" to "and". Is it possible?
I tried using replace function but it's not working:
var xml = xml.replace(/&/g, "and");
var request = new XMLHttpRequest();
request.open("GET", "/ODDS/odds3.xml", false);
request.send();
var xml = request.responseXML;
var xml = xml.replace(/&/g, "and");
var txt = "";
var txt2 = "";
var txt3 = "";
var users = xml.getElementsByTagName("match");
for (var i = 0; i < users.length; i++) {
var names = users[i];
for (j = 0; j < names.length; j++) {
txt += "MATCH: " + " id: " + names[j].getAttribute('id') + " he: " + names[j].getAttribute('he') + " < br > ";
}
}
document.getElementById("demo").innerHTML = txt;
This is my odds3.xml that has &
.
<match id="32375537" he="Brighton & Hove Albion">
I expected the output to display my datas from odds3.xml, from &
then replaced to and
. Thanks for the help!
CONSOLE LOG:
I added console.log(xml) but it returned "null" value, because the xml file have "&" on it.
Expected output:
MATCH: id: 32375537 he: Brighton and Hove Albion