1 |
<!DOCTYPE html> |
2 |
<html> |
3 |
<head> |
4 |
<title>DOM3 XPath vs HTML Document</title> |
5 |
</head> |
6 |
<body> |
7 |
<h1>DOM3 XPath vs HTML Document</h1> |
8 |
|
9 |
<div>A <code>div</code> element.</div> |
10 |
|
11 |
<Div>A <code>Div</code> element.</Div> |
12 |
|
13 |
<DIV>A <code>DIV</code> element.</DIV> |
14 |
|
15 |
<p id="status"></p> |
16 |
|
17 |
<script type="text/javascript"> |
18 |
document.getElementById ('status').appendChild |
19 |
(document.createTextNode ('FAIL')); |
20 |
var nl = document.evaluate ('//DIV', document, function () { |
21 |
return 'http://www.w3.org/1999/xhtml'; |
22 |
}, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); |
23 |
for (var i = 0; i < nl.snapshotLength; i++) { |
24 |
nl.snapshotItem (i).style.color = 'blue'; |
25 |
} |
26 |
document.getElementById ('status').firstChild.data |
27 |
= '"//DIV" elements are colored blue.'; |
28 |
</script> |
29 |
<noscript>NOSCRIPT</noscript> |
30 |
|
31 |
</body> |
32 |
</html> |