java.lang.Object | |
↳ | org.jsoup.select.Elements |
A list of Elements
, with methods that act on every element in the list
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add the class name to every matched element's
class attribute. | |||||||||||
Insert the supplied HTML after each matched element's outer HTML.
| |||||||||||
Add the supplied HTML to the end of each matched element's inner HTML.
| |||||||||||
Get an attribute value from the first matched element that has the attribute.
| |||||||||||
Set an attribute on all matched elements.
| |||||||||||
Insert the supplied HTML before each matched element's outer HTML.
| |||||||||||
Empty (remove all child nodes from) each matched element.
| |||||||||||
Get the nth matched element as an Elements object.
| |||||||||||
Get the first matched element.
| |||||||||||
Checks if any of the matched elements have this attribute set.
| |||||||||||
Determine if any of the matched elements have this class name set in their
class attribute. | |||||||||||
Get the combined inner HTML of all matched elements.
| |||||||||||
Set the inner HTML of each matched element.
| |||||||||||
Test if any of the matched elements match the supplied query.
| |||||||||||
Get the last matched element.
| |||||||||||
Remove elements from this list that do not match the
Selector query. | |||||||||||
Get the combined outer HTML of all matched elements.
| |||||||||||
Get all of the parents and ancestor elements of the matched elements.
| |||||||||||
Add the supplied HTML to the start of each matched element's inner HTML.
| |||||||||||
Remove each matched element from the DOM.
| |||||||||||
Remove an attribute from every matched element.
| |||||||||||
Remove the class name from every matched element's
class attribute, if present. | |||||||||||
Find matching elements within this element list.
| |||||||||||
Update the tag name of each matched element.
| |||||||||||
Get the combined text of all the matched elements.
| |||||||||||
Get the combined outer HTML of all matched elements.
| |||||||||||
Toggle the class name on every matched element's
class attribute. | |||||||||||
Get the form element's value of the first matched element.
| |||||||||||
Set the form element's value in each of the matched elements.
| |||||||||||
Wrap the supplied HTML around each matched elements.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
From interface
java.util.Collection
| |||||||||||
From interface
java.util.List
|
Add the class name to every matched element's class
attribute.
className | class name to add |
---|
Insert the supplied HTML after each matched element's outer HTML.
html | HTML to insert after each element |
---|
Add the supplied HTML to the end of each matched element's inner HTML.
html | HTML to add inside each element, after the existing HTML |
---|
Get an attribute value from the first matched element that has the attribute.
attributeKey | The attribute key. |
---|
Set an attribute on all matched elements.
attributeKey | attribute key |
---|---|
attributeValue | attribute value |
Insert the supplied HTML before each matched element's outer HTML.
html | HTML to insert before each element |
---|
Get the nth matched element as an Elements object.
See also get(int)
to retrieve an Element.
index | the (zero-based) index of the element in the list to retain |
---|
Get the first matched element.
null
if contents is empty;
Checks if any of the matched elements have this attribute set.
attributeKey | attribute key |
---|
Determine if any of the matched elements have this class name set in their class
attribute.
className | class name to check for |
---|
Get the combined inner HTML of all matched elements.
Set the inner HTML of each matched element.
html | HTML to parse and set into each matched element. |
---|
Test if any of the matched elements match the supplied query.
query | A selector |
---|
Get the last matched element.
null
if contents is empty.
Remove elements from this list that do not match the Selector
query.
E.g. HTML: <div class=logo>One</div> <div>Two</div>
Elements divs = doc.select("div").not("#logo");
Result: divs: [<div>Two</div>]
query | the selector query whose results should be removed from these elements |
---|
Add the supplied HTML to the start of each matched element's inner HTML.
html | HTML to add inside each element, before the existing HTML |
---|
Remove each matched element from the DOM. This is similar to setting the outer HTML of each element to nothing.
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 Cleaner
to clean HTML.
Remove an attribute from every matched element.
attributeKey | The attribute to remove. |
---|
Remove the class name from every matched element's class
attribute, if present.
className | class name to remove |
---|
Find matching elements within this element list.
query | A Selector query |
---|
Update the tag name of each matched element. For example, to change each <i>
to a <em>
, do
doc.select("i").tagName("em");
tagName | the new tag name |
---|
Get the combined text of all the matched elements.
Note that it is possible to get repeats if the matched elements contain both parent elements and their own children, as the Element.text() method returns the combined text of a parent and all its children.
Get the combined outer HTML of all matched elements. Alias of outerHtml()
.
Toggle the class name on every matched element's class
attribute.
className | class name to add if missing, or remove if present, from every element. |
---|
Get the form element's value of the first matched element.
Set the form element's value in each of the matched elements.
value | The value to set into each matched element |
---|
Wrap the supplied HTML around each matched elements. 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>
html | HTML to wrap around each element, e.g. <div class="head"></div> . Can be arbitrarily deep. |
---|