|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsoup.nodes.Node
org.jsoup.nodes.TextNode
public class TextNode
A text node.
| Constructor Summary | |
|---|---|
TextNode(String text,
String baseUri)
Create a new TextNode representing the supplied (unencoded) text). |
|
| Method Summary | |
|---|---|
String |
absUrl(String attributeKey)
Get an absolute URL from a URL attribute that may be relative (i.e. |
String |
attr(String attributeKey)
Get an attribute's value by its key. |
Node |
attr(String attributeKey,
String attributeValue)
Set an attribute (key=value). |
Attributes |
attributes()
Get all of the element's attributes. |
static TextNode |
createFromEncoded(String encodedText,
String baseUri)
Create a new TextNode from HTML encoded (aka escaped) data. |
String |
getWholeText()
Get the (unencoded) text of this text node, including any newlines and spaces present in the original. |
boolean |
hasAttr(String attributeKey)
Test if this element has an attribute. |
boolean |
isBlank()
Test if this text node is blank -- that is, empty or only whitespace (including newlines). |
String |
nodeName()
Get the node name of this node. |
Node |
removeAttr(String attributeKey)
Remove an attribute from this element. |
TextNode |
splitText(int offset)
Split this text node into two nodes at the specified string offset. |
String |
text()
Get the text content of this text node. |
TextNode |
text(String text)
Set the text content of this text node. |
String |
toString()
|
| Methods inherited from class org.jsoup.nodes.Node |
|---|
addChildren, addChildren, after, after, baseUri, before, before, childNode, childNodes, childNodesAsArray, childNodesCopy, childNodeSize, clone, doClone, equals, hashCode, indent, nextSibling, outerHtml, outerHtml, ownerDocument, parent, parentNode, previousSibling, remove, removeChild, replaceChild, replaceWith, setBaseUri, setParentNode, setSiblingIndex, siblingIndex, siblingNodes, traverse, unwrap, wrap |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TextNode(String text,
String baseUri)
text - raw textbaseUri - base uricreateFromEncoded(String, String)| Method Detail |
|---|
public String nodeName()
Node
nodeName in class Nodepublic String text()
getWholeText()public TextNode text(String text)
text - unencoded text
public String getWholeText()
public boolean isBlank()
public TextNode splitText(int offset)
offset - string offset point to split node at.
public String toString()
toString in class Node
public static TextNode createFromEncoded(String encodedText,
String baseUri)
encodedText - Text containing encoded HTML (e.g. <)
public String attr(String attributeKey)
Nodeabs,
which is a shortcut to the Node.absUrl(java.lang.String) method.
E.g.: String url = a.attr("abs:href");
attr in class NodeattributeKey - The attribute key.
Node.attributes(),
Node.hasAttr(String),
Node.absUrl(String)public Attributes attributes()
Node
attributes in class Node
public Node attr(String attributeKey,
String attributeValue)
Node
attr in class NodeattributeKey - The attribute key.attributeValue - The attribute value.
public boolean hasAttr(String attributeKey)
Node
hasAttr in class NodeattributeKey - The attribute key to check.
public Node removeAttr(String attributeKey)
Node
removeAttr in class NodeattributeKey - The attribute to remove.
public String absUrl(String attributeKey)
Node<a href> or
<img src>).
E.g.: 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 Node.baseUri, and made
absolute using that.
As an alternate, you can use the Node.attr(java.lang.String) method with the abs: prefix, e.g.:
String absUrl = linkEl.attr("abs:href");
absUrl in class NodeattributeKey - The attribute key
Node.attr(java.lang.String),
URL.URL(java.net.URL, String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||