@Test public void traverse() { Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>"); final StringBuilder accum = new StringBuilder(); doc.select("div").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><div><#text></#text></div>", accum.toString()); }
public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; }
Elements extends ArrayList<Element> { public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; } }
Elements extends ArrayList<Element> { public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; } Elements();  Elements(int initialCapacity);  Elements(Collection<Element> elements);  Elements(List<Element> elements);  Elements(Element... elements); }
Elements extends ArrayList<Element> { public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; } Elements();  Elements(int initialCapacity);  Elements(Collection<Element> elements);  Elements(List<Element> elements);  Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms(); }
Elements extends ArrayList<Element> { public Elements traverse(NodeVisitor nodeVisitor) { Validate.notNull(nodeVisitor); NodeTraversor traversor = new NodeTraversor(nodeVisitor); for (Element el: this) { traversor.traverse(el); } return this; } Elements();  Elements(int initialCapacity);  Elements(Collection<Element> elements);  Elements(List<Element> elements);  Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms();  }