1 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
2 |
<head> |
3 |
<title>createDocument</title> |
4 |
<script src="../../../support/result.js"></script> |
5 |
</head> |
6 |
<body> |
7 |
|
8 |
<p id="result-document"></p> |
9 |
|
10 |
<h1>The Document</h1> |
11 |
<ul id="list-document"></ul> |
12 |
|
13 |
<h1>The Document Element</h1> |
14 |
<ul id="list-document-element"></ul> |
15 |
|
16 |
<script> |
17 |
var d = document.implementation.createDocument (null, null, null); |
18 |
setResult ('result-document', d); |
19 |
|
20 |
if (d) { |
21 |
var i = 0; |
22 |
var ul = document.getElementsByTagName ('ul')[0]; |
23 |
for (var v in d) { |
24 |
var li = document.createElementNS ('http://www.w3.org/1999/xhtml', 'li'); |
25 |
li.textContent = ': '; |
26 |
li.insertBefore (document.createElementNS ('http://www.w3.org/1999/xhtml', 'code'), |
27 |
li.firstChild) |
28 |
.textContent = v; |
29 |
li.appendChild (document.createElementNS ('http://www.w3.org/1999/xhtml', 'span')) |
30 |
.setAttributeNS (null, 'id', 'item-' + i); |
31 |
ul.appendChild (li); |
32 |
try { |
33 |
setResult ('item-' + i, d[v]); |
34 |
} catch (e) { |
35 |
document.getElementById ('item-' + i).textContent = 'ERROR: ' + e; |
36 |
} |
37 |
i++; |
38 |
} |
39 |
|
40 |
var de = d.documentElement; |
41 |
if (de) { |
42 |
var ul = document.getElementsByTagName ('ul')[1]; |
43 |
for (var v in de) { |
44 |
var li = document.createElementNS ('http://www.w3.org/1999/xhtml', 'li'); |
45 |
li.textContent = ': '; |
46 |
li.insertBefore (document.createElementNS ('http://www.w3.org/1999/xhtml', 'code'), |
47 |
li.firstChild) |
48 |
.textContent = v; |
49 |
li.appendChild (document.createElementNS ('http://www.w3.org/1999/xhtml', 'span')) |
50 |
.setAttributeNS (null, 'id', 'item-' + i); |
51 |
ul.appendChild (li); |
52 |
try { |
53 |
setResult ('item-' + i, de[v]); |
54 |
} catch (e) { |
55 |
document.getElementById ('item-' + i).textContent = 'ERROR: ' + e; |
56 |
} |
57 |
i++; |
58 |
} |
59 |
} |
60 |
} |
61 |
</script> |
62 |
|
63 |
</body> |
64 |
</html> |