Мне нужно отобразить данные XML в таблице в файле HTML.
Я пытаюсь отключить все свои расширения в FireFox, но у меня все еще появляется пустой экран.
Сведения о сотрудниках
<script>
var client;
if (window.XMLHttpRequest) {
client = new XMLHttpRequest();
}
else {
client = new ActiveXObject("Microsoft.XMLHTTP");
}
client.open('GET', 'employees.xml', false);
client.onreadystatechange = function() { // will run when the file loads
// get the response XML
var xmlDoc = client.responseXML;
// get the list of user
var user = xmlDoc.getElementsByTagName("user");
// get the container where you want to embed the table
var container = document.getElementById("container");
var tableString = "<table border='1'>"; // Make a table and put the element data inside it
for (i = 0; i < user.length; i++) {
tableString += "<tr><td>";
tableString += user[i].getElementsByTagName("Firstname")[0].childNodes[0].nodeValue;
tableString +="</td><td>";
tableString += user[i].getElementsByTagName("Phone")[0].childNodes[0].nodeValue;
tableString += "</td></tr>";
}
tableString += "</table>";
// append the table to the container
container.innerHTML = tableString;
}
client.send();
</script>
<body>
<h1></h1>
<div id="container"></div>
</body>
<?xml version = "1.0" encoding ="UTF-16"?>
<user_information>
<user id="1">
<Firstname> Bobby </Firstname>
<Lastname>Drake</Lastname>
<major>Criminal Justice</major>
<location>Illinois</location>
<Phone>(923)949-2302</Phone>
</user>
<user>
<Firstname>Scott</Firstname>
<Lastname>Summers</Lastname>
<major> </major>
<location> California </location>
<Phone>(395)984-7284</Phone>
</user>
<user>
<Firstname>Jean</Firstname>
<Lastname>Grey</Lastname>
<major> </major>
<location>New York</location>
<Phone>(843)759-6943</Phone>
</user>
<user>
<Firstname>Kevin</Firstname>
<Lastname>Sydney</Lastname>
<major> </major>
<location>New York</location>
<Phone>(571)-089-4568</Phone>
</user>
<user>
<Firstname>Suzanne</Firstname>
<Lastname>Chan</Lastname>
<major> </major>
<location>Illinois</location>
<Phone>(685)-583-2849</Phone>
</user>
</user_information>
При открытии HTML-кода в FireFox появляется пустой экран. Я не знаю, является ли это мой код или что-то на моем компьютере. Буду очень признателен, если кто-нибудь сможет мне помочь.