<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>nodeIterator</title>
<script type="text/javascript">
window.onload = function() {
var div = document.getElementById("div1");
var iterator = document.createNodeIterator(div,
NodeFilter.SHOW_ELEMENT, null, false);
var node = iterator.nextNode();
while (node !== null) {
alert(node.tagName);
node = iterator.nextNode();
}
}
</script>
</head>
<body>
<div id="div1">
<p>
<b>Hello</b> world!
</p>
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>
</div>
</body>
</html>