|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsoup.select.Elements
public class Elements
A list of Elements, with methods that act on every element in the list.
Element.select(String) method.
| Constructor Summary | |
|---|---|
Elements()
|
|
Elements(java.util.Collection<Element> elements)
|
|
Elements(Element... elements)
|
|
Elements(java.util.List<Element> elements)
|
|
| Method Summary | ||
|---|---|---|
boolean |
add(Element element)
|
|
void |
add(int index,
Element element)
|
|
boolean |
addAll(java.util.Collection<? extends Element> c)
|
|
boolean |
addAll(int index,
java.util.Collection<? extends Element> c)
|
|
Elements |
addClass(java.lang.String className)
Add the class name to every matched element's class attribute. |
|
Elements |
after(java.lang.String html)
Insert the supplied HTML after each matched element's outer HTML. |
|
Elements |
append(java.lang.String html)
Add the supplied HTML to the end of each matched element's inner HTML. |
|
java.lang.String |
attr(java.lang.String attributeKey)
Get an attribute value from the first matched element that has the attribute. |
|
Elements |
attr(java.lang.String attributeKey,
java.lang.String attributeValue)
Set an attribute on all matched elements. |
|
Elements |
before(java.lang.String html)
Insert the supplied HTML before each matched element's outer HTML. |
|
void |
clear()
|
|
Elements |
clone()
|
|
boolean |
contains(java.lang.Object o)
|
|
boolean |
containsAll(java.util.Collection<?> c)
|
|
Elements |
empty()
Empty (remove all child nodes from) each matched element. |
|
Elements |
eq(int index)
Get the nth matched element as an Elements object. |
|
boolean |
equals(java.lang.Object o)
|
|
Element |
first()
Get the first matched element. |
|
Element |
get(int index)
|
|
boolean |
hasAttr(java.lang.String attributeKey)
Checks if any of the matched elements have this attribute set. |
|
boolean |
hasClass(java.lang.String className)
Determine if any of the matched elements have this class name set in their class attribute. |
|
int |
hashCode()
|
|
boolean |
hasText()
|
|
java.lang.String |
html()
Get the combined inner HTML of all matched elements. |
|
Elements |
html(java.lang.String html)
Set the inner HTML of each matched element. |
|
int |
indexOf(java.lang.Object o)
|
|
boolean |
is(java.lang.String query)
Test if any of the matched elements match the supplied query. |
|
boolean |
isEmpty()
|
|
java.util.Iterator<Element> |
iterator()
|
|
Element |
last()
Get the last matched element. |
|
int |
lastIndexOf(java.lang.Object o)
|
|
java.util.ListIterator<Element> |
listIterator()
|
|
java.util.ListIterator<Element> |
listIterator(int index)
|
|
Elements |
not(java.lang.String query)
Remove elements from this list that do not match the Selector query. |
|
java.lang.String |
outerHtml()
Get the combined outer HTML of all matched elements. |
|
Elements |
parents()
Get all of the parents and ancestor elements of the matched elements. |
|
Elements |
prepend(java.lang.String html)
Add the supplied HTML to the start of each matched element's inner HTML. |
|
Elements |
remove()
Remove each matched element from the DOM. |
|
Element |
remove(int index)
|
|
boolean |
remove(java.lang.Object o)
|
|
boolean |
removeAll(java.util.Collection<?> c)
|
|
Elements |
removeAttr(java.lang.String attributeKey)
Remove an attribute from every matched element. |
|
Elements |
removeClass(java.lang.String className)
Remove the class name from every matched element's class attribute, if present. |
|
boolean |
retainAll(java.util.Collection<?> c)
|
|
Elements |
select(java.lang.String query)
Find matching elements within this element list. |
|
Element |
set(int index,
Element element)
|
|
int |
size()
|
|
java.util.List<Element> |
subList(int fromIndex,
int toIndex)
|
|
Elements |
tagName(java.lang.String tagName)
Update the tag name of each matched element. |
|
java.lang.String |
text()
Get the combined text of all the matched elements. |
|
java.lang.Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
Elements |
toggleClass(java.lang.String className)
Toggle the class name on every matched element's class attribute. |
|
java.lang.String |
toString()
Get the combined outer HTML of all matched elements. |
|
Elements |
traverse(NodeVisitor nodeVisitor)
Perform a depth-first traversal on each of the selected elements. |
|
Elements |
unwrap()
Removes the matched elements from the DOM, and moves their children up into their parents. |
|
java.lang.String |
val()
Get the form element's value of the first matched element. |
|
Elements |
val(java.lang.String value)
Set the form element's value in each of the matched elements. |
|
Elements |
wrap(java.lang.String html)
Wrap the supplied HTML around each matched elements. |
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Elements()
public Elements(java.util.Collection<Element> elements)
public Elements(java.util.List<Element> elements)
public Elements(Element... elements)
| Method Detail |
|---|
public Elements clone()
clone in class java.lang.Objectpublic java.lang.String attr(java.lang.String attributeKey)
attributeKey - The attribute key.
hasAttr(String)public boolean hasAttr(java.lang.String attributeKey)
attributeKey - attribute key
public Elements attr(java.lang.String attributeKey,
java.lang.String attributeValue)
attributeKey - attribute keyattributeValue - attribute value
public Elements removeAttr(java.lang.String attributeKey)
attributeKey - The attribute to remove.
public Elements addClass(java.lang.String className)
class attribute.
className - class name to add
public Elements removeClass(java.lang.String className)
class attribute, if present.
className - class name to remove
public Elements toggleClass(java.lang.String className)
class attribute.
className - class name to add if missing, or remove if present, from every element.
public boolean hasClass(java.lang.String className)
class attribute.
className - class name to check for
public java.lang.String val()
Element.val()public Elements val(java.lang.String value)
value - The value to set into each matched element
public java.lang.String text()
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.
Element.text()public boolean hasText()
public java.lang.String html()
text(),
outerHtml()public java.lang.String outerHtml()
text(),
html()public java.lang.String toString()
outerHtml().
toString in class java.lang.Objecttext(),
html()public Elements tagName(java.lang.String tagName)
<i> to a <em>, do
doc.select("i").tagName("em");
tagName - the new tag name
Element.tagName(String)public Elements html(java.lang.String html)
html - HTML to parse and set into each matched element.
Element.html(String)public Elements prepend(java.lang.String html)
html - HTML to add inside each element, before the existing HTML
Element.prepend(String)public Elements append(java.lang.String html)
html - HTML to add inside each element, after the existing HTML
Element.append(String)public Elements before(java.lang.String html)
html - HTML to insert before each element
Element.before(String)public Elements after(java.lang.String html)
html - HTML to insert after each element
Element.after(String)public Elements wrap(java.lang.String 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.
Element.wrap(java.lang.String)public Elements unwrap()
<div><font>One</font> <font><a href="/">Two</a></font></div>doc.select("font").unwrap();<div>One <a href="/">Two</a></div>
Node.unwrap()public Elements empty()
E.g. HTML: <div><p>Hello <b>there</b></p> <p>now</p></div>
doc.select("p").empty();
HTML = <div><p></p> <p></p></div>
Element.empty(),
remove()public Elements remove()
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.
Element.empty(),
empty()public Elements select(java.lang.String query)
query - A Selector query
public Elements not(java.lang.String query)
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
public Elements eq(int index)
See also get(int) to retrieve an Element.
index - the (zero-based) index of the element in the list to retain
public boolean is(java.lang.String query)
query - A selector
public Elements parents()
public Element first()
null if contents is empty;public Element last()
null if contents is empty.public Elements traverse(NodeVisitor nodeVisitor)
nodeVisitor - the visitor callbacks to perform on each node
public int size()
size in interface java.util.Collection<Element>size in interface java.util.List<Element>public boolean isEmpty()
isEmpty in interface java.util.Collection<Element>isEmpty in interface java.util.List<Element>public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<Element>contains in interface java.util.List<Element>public java.util.Iterator<Element> iterator()
iterator in interface java.lang.Iterable<Element>iterator in interface java.util.Collection<Element>iterator in interface java.util.List<Element>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<Element>toArray in interface java.util.List<Element>public <T> T[] toArray(T[] a)
toArray in interface java.util.Collection<Element>toArray in interface java.util.List<Element>public boolean add(Element element)
add in interface java.util.Collection<Element>add in interface java.util.List<Element>public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<Element>remove in interface java.util.List<Element>public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<Element>containsAll in interface java.util.List<Element>public boolean addAll(java.util.Collection<? extends Element> c)
addAll in interface java.util.Collection<Element>addAll in interface java.util.List<Element>
public boolean addAll(int index,
java.util.Collection<? extends Element> c)
addAll in interface java.util.List<Element>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<Element>removeAll in interface java.util.List<Element>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<Element>retainAll in interface java.util.List<Element>public void clear()
clear in interface java.util.Collection<Element>clear in interface java.util.List<Element>public boolean equals(java.lang.Object o)
equals in interface java.util.Collection<Element>equals in interface java.util.List<Element>equals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.Collection<Element>hashCode in interface java.util.List<Element>hashCode in class java.lang.Objectpublic Element get(int index)
get in interface java.util.List<Element>
public Element set(int index,
Element element)
set in interface java.util.List<Element>
public void add(int index,
Element element)
add in interface java.util.List<Element>public Element remove(int index)
remove in interface java.util.List<Element>public int indexOf(java.lang.Object o)
indexOf in interface java.util.List<Element>public int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.List<Element>public java.util.ListIterator<Element> listIterator()
listIterator in interface java.util.List<Element>public java.util.ListIterator<Element> listIterator(int index)
listIterator in interface java.util.List<Element>
public java.util.List<Element> subList(int fromIndex,
int toIndex)
subList in interface java.util.List<Element>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||