Node implements Cloneable { public Node traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); traversor.traverse(this); return this; } protected  Node(String baseUri, Attributes attributes); protected  Node(String baseUri); protected  Node(); abstract String nodeName(); String attr(String attributeKey); Attributes attributes(); Node attr(String attributeKey, String attributeValue); boolean hasAttr(String attributeKey); Node removeAttr(String attributeKey); String baseUri(); void setBaseUri(final String baseUri); String absUrl(String attributeKey); Node childNode(int index); List<Node> childNodes(); List<Node> childNodesCopy(); final int childNodeSize(); Node parent(); final Node parentNode(); Document ownerDocument(); void remove(); Node before(String html); Node before(Node node); Node after(String html); Node after(Node node); Node wrap(String html); Node unwrap(); void replaceWith(Node in); List<Node> siblingNodes(); Node nextSibling(); Node previousSibling(); int siblingIndex(); Node traverse(NodeVisitor nodeVisitor); String outerHtml(); String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override Node clone();  }
@Test public void traverse() { Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>"); final StringBuilder accum = new StringBuilder(); doc.select("div").first().traverse(new NodeVisitor() { public void head(Node node, int depth) { accum.append("<" + node.nodeName() + ">"); } public void tail(Node node, int depth) { accum.append("</" + node.nodeName() + ">"); } }); assertEquals("<div><p><#text></#text></p></div>", accum.toString()); }