Class Nodes<T extends Node>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractList<T>
java.util.ArrayList<T>
org.jsoup.select.Nodes<T>
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess, SequencedCollection<T>
- Direct Known Subclasses:
Elements
-
Field Summary
Fields inherited from class AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInsert the supplied HTML after each matched nodes's outer HTML.asList()Convenience method to get the Nodes as a plain ArrayList.Insert the supplied HTML before each matched node's outer HTML.voidclear()Removes all the nodes from this list, and each of them from the DOM.clone()Creates a deep copy of these nodes.deselect(int index) Remove the node at the specified index in this list, but not from the DOM.booleanRemove the specified node from this list, but not from the DOM.voidLikeclear(), removes all the nodes from this list, but not from the DOM.@Nullable Tfirst()Get the first matched element.@Nullable Tlast()Get the last matched element.Get the combined outer HTML of all matched nodes.remove()Remove each matched node from the DOM.remove(int index) Remove the node at the specified index in this list, and from the DOM.booleanRemove the specified node from this list, and from the DOM.booleanremoveAll(Collection<?> c) Removes from this list, and from the DOM, each of the nodes that are contained in the specified collection and are in this list.booleanRemove from the list, and from the DOM, all nodes in this list that mach the given predicate.voidreplaceAll(UnaryOperator<T> operator) Replace each node in this list with the result of the operator, and update the DOM.booleanretainAll(Collection<?> toRemove) Retain in this list, and in the DOM, only the nodes that are in the specified collection and are in this list.Replace the node at the specified index in this list, and in the DOM.toString()Get the combined outer HTML of all matched nodes.Wrap the supplied HTML around each matched node.Methods inherited from class ArrayList
add, add, addAll, addAll, addFirst, addLast, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeFirst, removeLast, removeRange, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class AbstractCollection
containsAllMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface List
containsAll, reversed
-
Constructor Details
-
Nodes
public Nodes() -
Nodes
-
Nodes
-
Nodes
-
Nodes
-
-
Method Details
-
clone
-
asList
Convenience method to get the Nodes as a plain ArrayList. This allows modification to the list of nodes without modifying the source Document. I.e. whereas callingnodes.remove(0)will remove the nodes from both the Nodes and the DOM,nodes.asList().remove(0)will remove the node from the list only.Each Node is still the same DOM connected Node.
- Returns:
- a new ArrayList containing the nodes in this list
- See Also:
-
remove
Remove each matched node from the DOM.The nodes will still be retained in this list, in case further processing of them is desired.
E.g. HTML:
<div><p>Hello</p> <p>there</p> <img></div>
doc.select("p").remove();
HTML =<div> <img></div>Note that this method should not be used to clean user-submitted HTML; rather, use
Cleanerto clean HTML.- Returns:
- this, for chaining
- See Also:
-
outerHtml
-
toString
Get the combined outer HTML of all matched nodes. Alias ofouterHtml().- Overrides:
toStringin classAbstractCollection<T extends Node>- Returns:
- string of all the node's outer HTML.
- See Also:
-
before
-
after
-
wrap
Wrap the supplied HTML around each matched node. For example, with HTML<p><b>This</b> is <b>Jsoup</b></p>,doc.select("b").wrap("<i></i>");becomes<p><i><b>This</b></i> is <i><b>jsoup</b></i></p>- Parameters:
html- HTML to wrap around each node, e.g.<div class="head"></div>. Can be arbitrarily deep.- Returns:
- this (for chaining)
- See Also:
-
first
-
last
-
set
Replace the node at the specified index in this list, and in the DOM. -
remove
Remove the node at the specified index in this list, and from the DOM. -
remove
Remove the specified node from this list, and from the DOM. -
deselect
-
deselect
-
clear
-
deselectAll
Likeclear(), removes all the nodes from this list, but not from the DOM.- See Also:
-
removeAll
Removes from this list, and from the DOM, each of the nodes that are contained in the specified collection and are in this list.- Specified by:
removeAllin interfaceCollection<T extends Node>- Specified by:
removeAllin interfaceList<T extends Node>- Overrides:
removeAllin classArrayList<T extends Node>- Parameters:
c- collection containing nodes to be removed from this list- Returns:
trueif nodes were removed from this list
-
retainAll
Retain in this list, and in the DOM, only the nodes that are in the specified collection and are in this list. In other words, remove nodes from this list and the DOM any item that is in this list but not in the specified collection.- Specified by:
retainAllin interfaceCollection<T extends Node>- Specified by:
retainAllin interfaceList<T extends Node>- Overrides:
retainAllin classArrayList<T extends Node>- Parameters:
toRemove- collection containing nodes to be retained in this list- Returns:
trueif nodes were removed from this list- Since:
- 1.17.1
-
removeIf
Remove from the list, and from the DOM, all nodes in this list that mach the given predicate. -
replaceAll
Replace each node in this list with the result of the operator, and update the DOM.- Specified by:
replaceAllin interfaceList<T extends Node>- Overrides:
replaceAllin classArrayList<T extends Node>- Parameters:
operator- the operator to apply to each node
-