chromium/third_party/blink/web_tests/traversal/tree-walker-006.html

<html> 
<head>
<title>Traversal Test</title> 
</head> 
<body>

  <h2>XML doc elements:</h2>
  <div style="font-family: Courier; font-size: 14;">
    <script type="text/javascript" charset="utf-8">

    if (window.testRunner)
        testRunner.dumpAsText();

      var dataURL = 'resources/node-iterator-009-data.xml';
      function fetchXML()
      {
        var request = new XMLHttpRequest();
        request.open("GET", dataURL, false /* sync */);
        request.overrideMimeType("application/xml");
        request.send();

        if (request.readyState == 4) {
          // only if "OK"
          if (request.status == 200 || (request.status == 0 && request.responseText.length > 0))
              walkXML(request.responseXML);
        }
      }

      function testNodeFiter(n)
      {
          if (n.tagName == 'studio') return NodeFilter.FILTER_SKIP;
          return NodeFilter.FILTER_ACCEPT;
      }

      function walkXML(xmlDoc)
      {
        var iter = document.createTreeWalker(xmlDoc, NodeFilter.SHOW_ELEMENT, testNodeFiter, false);
        var curNode;
        while (curNode = iter.nextNode()) {
          document.write('<h3>' + curNode.tagName + '</h3><p>' + curNode.textContent + '</p>');
        }
      }
      fetchXML();

    </script>
  </div>
</body>
</html>