-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadxml.html
60 lines (57 loc) · 2.28 KB
/
loadxml.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
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<title>Semester Marksheet</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript">
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
}
function loadMarksheetXML()
{
xmlDoc=loadXMLDoc("marksheet.xml");
x=xmlDoc.getElementsByTagName("course");
var divText="<table>"+
"<tr><th>Course ID</th><th>Title</th>"+
"<th>TH</th><th>IA</th><th>TW</th>"+
"<th>OR/PR</th><th>Total</th></tr>";
for (i=0;i<x.length;i++)
{
courseid=xmlDoc.getElementsByTagName("courseid")[i].childNodes[0].nodeValue;
title=xmlDoc.getElementsByTagName("title")[i].childNodes[0].nodeValue;
th=xmlDoc.getElementsByTagName("TH")[i].childNodes[0].nodeValue;
ia=xmlDoc.getElementsByTagName("IA")[i].childNodes[0].nodeValue;
tw=xmlDoc.getElementsByTagName("TW")[i].childNodes[0].nodeValue;
orpr=xmlDoc.getElementsByTagName("ORPR")[i].childNodes[0].nodeValue;
total=xmlDoc.getElementsByTagName("total")[i].childNodes[0].nodeValue;
divText +="<tr><td>"+courseid+"</td><td>"+title
+"</td>"+
"<td>"+th+"</td><td>"+ia+"</td><td>"+tw
+"</td>"+
"<td>"+orpr+"</td><td>"+total+"</td></tr>";
}
divText +="</table>";
document.getElementById("marksheet").innerHTML
= divText;
}
</script>
</head>
<body>
<input type="submit" onclick="loadMarksheetXML()" />
<div id="marksheet">
</div>
</body>
</html>