java.lang.Object | |
↳ | org.jsoup.nodes.Node |
Known Direct Subclasses |
Known Indirect Subclasses |
The base, abstract Node model. Elements, Documents, Comments etc are all Node instances.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new Node.
| |||||||||||
Default constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Get an absolute URL from a URL attribute that may be relative (i.e.
| |||||||||||
Insert the specified HTML into the DOM after this node (i.e.
| |||||||||||
Set an attribute (key=value).
| |||||||||||
Get an attribute's value by its key.
| |||||||||||
Get all of the element's attributes.
| |||||||||||
Get the base URI of this node.
| |||||||||||
Insert the specified HTML into the DOM before this node (i.e.
| |||||||||||
Get a child node by index
| |||||||||||
Get this node's children.
| |||||||||||
Create a stand-alone, deep copy of this node, and all of its children.
| |||||||||||
Test if this element has an attribute.
| |||||||||||
Get this node's next sibling.
| |||||||||||
Get the node name of this node.
| |||||||||||
Get the outer HTML of this node.
| |||||||||||
Gets the Document associated with this Node.
| |||||||||||
Gets this node's parent node.
| |||||||||||
Get this node's previous sibling.
| |||||||||||
Remove (delete) this node from the DOM tree.
| |||||||||||
Remove an attribute from this element.
| |||||||||||
Replace this node in the DOM with the supplied node.
| |||||||||||
Update the base URI of this node.
| |||||||||||
Get the list index of this node in its node sibling list.
| |||||||||||
Retrieves this node's sibling nodes.
| |||||||||||
Wrap the supplied HTML around this node.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a new Node.
baseUri | base URI |
---|---|
attributes | attributes (not null, but may be empty) |
Default constructor. Doesn't setup base uri, children, or attributes; use with caution.
Get an absolute URL from a URL attribute that may be relative (i.e. an <a href>
or
<img src>
).
String absUrl = linkEl.absUrl("href");
If the attribute value is already absolute (i.e. it starts with a protocol, like
http://
or https://
etc), and it successfully parses as a URL, the attribute is
returned directly. Otherwise, it is treated as a URL relative to the element's baseUri()
, and made
absolute using that.
As an alternate, you can use the attr(String)
method with the abs:
prefix, e.g.:
String absUrl = linkEl.attr("abs:href");
attributeKey | The attribute key |
---|
Insert the specified HTML into the DOM after this node (i.e. as a following sibling).
html | HTML to add after this element |
---|
Set an attribute (key=value). If the attribute already exists, it is replaced.
attributeKey | The attribute key. |
---|---|
attributeValue | The attribute value. |
Get an attribute's value by its key.
To get an absolute URL from an attribute that may be a relative URL, prefix the key withabs
,
which is a shortcut to the absUrl(String)
method.
E.g.: String url = a.attr("abs:href");
attributeKey | The attribute key. |
---|
Get all of the element's attributes.
Insert the specified HTML into the DOM before this node (i.e. as a preceeding sibling).
html | HTML to add before this element |
---|
Get a child node by index
index | index of child node |
---|
Get this node's children. Presented as an unmodifiable list: new children can not be added, but the child nodes themselves can be manipulated.
Create a stand-alone, deep copy of this node, and all of its children. The cloned node will have no siblings or parent node. As a stand-alone object, any changes made to the clone or any of its children will not impact the original node.
The cloned node may be adopted into another Document or node structure using appendChild(Node)
.
Test if this element has an attribute.
attributeKey | The attribute key to check. |
---|
Get this node's next sibling.
Get the node name of this node. Use for debugging purposes and not logic switching (for that, use instanceof).
Gets the Document associated with this Node.
Get this node's previous sibling.
Remove (delete) this node from the DOM tree. If this node has children, they are also removed.
Remove an attribute from this element.
attributeKey | The attribute to remove. |
---|
Replace this node in the DOM with the supplied node.
in | the node that will will replace the existing node. |
---|
Update the base URI of this node.
baseUri | base URI to set |
---|
Get the list index of this node in its node sibling list. I.e. if this is the first node sibling, returns 0.
Retrieves this node's sibling nodes. Effectively, node.parent.childNodes()
.
Wrap the supplied HTML around this node.
html | HTML to wrap around this element, e.g. <div class="head"></div> . Can be arbitrarily deep. |
---|