Class NodeTraversor

java.lang.Object
org.jsoup.select.NodeTraversor

public class NodeTraversor
extends Object
Depth-first node traversor. Use to iterate through all nodes under and including the specified root node.

This implementation does not use recursion, so a deep DOM does not risk blowing the stack.

  • Constructor Details

  • Method Details

    • traverse

      public static void traverse(NodeVisitor visitor, Node root)
      Start a depth-first traverse of the root and all of its descendants.
      Parameters:
      visitor - Node visitor.
      root - the root node point to traverse.
    • traverse

      public static void traverse(NodeVisitor visitor, Elements elements)
      Start a depth-first traverse of all elements.
      Parameters:
      visitor - Node visitor.
      elements - Elements to filter.
    • filter

      public static NodeFilter.FilterResult filter(NodeFilter filter, Node root)
      Start a depth-first filtering of the root and all of its descendants.
      Parameters:
      filter - Node visitor.
      root - the root node point to traverse.
      Returns:
      The filter result of the root node, or NodeFilter.FilterResult.STOP.
    • filter

      public static void filter(NodeFilter filter, Elements elements)
      Start a depth-first filtering of all elements.
      Parameters:
      filter - Node filter.
      elements - Elements to filter.