-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmlDOM.html
More file actions
34 lines (31 loc) · 901 Bytes
/
Copy pathxmlDOM.html
File metadata and controls
34 lines (31 loc) · 901 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>HTML-XML DOM</title>
</head>
<body>
<div>
<b>Name:</b><span id="name"></span><br>
<b>Company:</b><span id="company"></span><br>
<b>Phone:</b><span id="phone"></span>
</div>
<script type="text/javascript">
if (window.XMLHttpRequest) {
// code for modern browsers
xmlhttp = new XMLHttpRequest();
} else {
// code for old IE browsers
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","/xml/xmlDOM.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.getElementsById("name").innerHTML=
xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue;
document.getElementsById("company").innerHTML=
xmlDoc.getElementsByTagName("company")[0].childNodes[0].nodeValue;
document.getElementsById("phone").innerHTML=
xmlDoc.getElementsByTagName("phone")[0].childNodes[0].nodeValue;
</script>
</body>
</html>