1 |
<!DOCTYPE html> |
2 |
<html lang="en"> |
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 class="a">An element with <code>class</code>.</div> |
10 |
|
11 |
<div Class="b">An element with <code>Class</code>.</div> |
12 |
|
13 |
<div CLASS="c">An element with <code>CLASS</code>.</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 ('//*[@node ()[local-name () = "CLASS"]]', document, null, |
21 |
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); |
22 |
for (var i = 0; i < nl.snapshotLength; i++) { |
23 |
nl.snapshotItem (i).style.color = 'blue'; |
24 |
} |
25 |
document.getElementById ('status').firstChild.data |
26 |
= '"//*[@node ()[local-name () = "CLASS"]]" elements are colored blue.'; |
27 |
</script> |
28 |
<noscript>NOSCRIPT</noscript> |
29 |
|
30 |
</body> |
31 |
</html> |