-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreview.html
56 lines (46 loc) · 1.7 KB
/
review.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id = "content">
<table id="friends">
<thead>
<th> Name </th><hr>
<th> Likes </th><hr>
<th> Dislikes </th><hr>
</thead>
<tbody></tbody>
</table>
</div>
<script>
let xmlContent ='';
let tableFriends = document.getElementById("friends");
fetch('review.xml').then((response)=>{
response.text().then((xml)=>{
xmlContent = xml;
let parser = new DOMParser();
let xmlDOM = parser.parseFromString(xmlContent,'application/xml');
let friends = xmlDOM.querySelectorAll("friend");
friends.forEach(friendXmlNode => {
let row = document.createElement('tr');
//name
let td = document.createElement('td');
td.innerText = friendXmlNode.children[0].innerHTML;
row.appendChild(td);
td = document.createElement('td');
td.innerText = friendXmlNode.children[1].innerHTML;
row.appendChild(td);
td = document.createElement('td');
td.innerText = friendXmlNode.children[2].innerHTML;
row.appendChild(td);
tableFriends.children[1].appendChild(row);
});
});
});
</script>
</body>
</html>