-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnordine6.html
41 lines (38 loc) · 1.24 KB
/
nordine6.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Exemple de chargement XML</title>
</head>
<body>
<h1>Contenu du document XML</h1>
<div id="content"></div>
<script>
function loadXMLDoc(filename) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
displayContent(this);
}
};
xhttp.open("GET", filename, true);
xhttp.send();
}
function displayContent(xml) {
var xmlDoc = xml.responseXML;
var x = xmlDoc.getElementsByTagName("root")[0].childNodes;
var content = document.getElementById("content");
for (let i = 0; i < x.length; i++) {
if (x[i].nodeType == 1) { // élément
var para = document.createElement("p");
para.textContent = x[i].textContent;
content.appendChild(para);
}
}
}
window.onload = function() {
loadXMLDoc("egusphere-2024-543.xml");
};
</script>
</body>
</html>