| 1 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 2 |
<head> |
| 3 |
<title>DOM3 XPath and Default Namespace</title> |
| 4 |
</head> |
| 5 |
<body> |
| 6 |
<h1>DOM3 XPath and Default Namespace</h1> |
| 7 |
|
| 8 |
<p>XPath expression <code>//div</code> with a namespace resolver |
| 9 |
that returns the HTML namespace...</p> |
| 10 |
|
| 11 |
<dl> |
| 12 |
<dt><code><div xmlns=""/></code></dt> |
| 13 |
<dd><div xmlns="">DON'T MATCH</div></dd> |
| 14 |
<dt><code><div xmlns="http://www.w3.org/1999/xhtml"/></code></dt> |
| 15 |
<dd><div xmlns="http://www.w3.org/1999/xhtml">DON'T MATCH</div></dd> |
| 16 |
<dt><code><h:div xmlns:h="http://www.w3.org/1999/xhtml"/></code></dt> |
| 17 |
<dd><h:div xmlns:h="http://www.w3.org/1999/xhtml">DON'T MATCH</h:div></dd> |
| 18 |
</dl> |
| 19 |
|
| 20 |
<script type="text/javascript"> |
| 21 |
var nl = document.evaluate ('//div', document, function () { |
| 22 |
return 'http://www.w3.org/1999/xhtml'; |
| 23 |
}, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); |
| 24 |
for (var i = 0; i < nl.snapshotLength; i++) { |
| 25 |
nl.snapshotItem (i).textContent = 'MATCH'; |
| 26 |
} |
| 27 |
</script> |
| 28 |
|
| 29 |
</body> |
| 30 |
</html> |