Modifier and Type | Field and Description |
---|---|
static String |
PUBLIC_KEY |
static String |
SYSTEM_KEY |
Constructor and Description |
---|
DocumentType(String name,
String publicId,
String systemId)
Create a new doctype element.
|
Modifier and Type | Method and Description |
---|---|
String |
absUrl(String key)
Get an absolute URL from a URL attribute that may be relative (such as an
<a href> or
<img src> ). |
String |
attr(String key)
Get an attribute's value by its key.
|
Node |
attr(String key,
String value)
Set an attribute (key=value).
|
Attributes |
attributes()
Get all of the element's attributes.
|
String |
baseUri()
Get the base URI that applies to this node.
|
int |
childNodeSize()
Get the number of child nodes that this node holds.
|
protected org.jsoup.nodes.LeafNode |
doClone(Node parent) |
protected void |
doSetBaseUri(String baseUri)
Set the baseUri for just this node (not its descendants), if this Node tracks base URIs.
|
Node |
empty()
Delete all this node's children.
|
protected List<Node> |
ensureChildNodes() |
boolean |
hasAttr(String key)
Test if this Node has an attribute.
|
protected boolean |
hasAttributes()
Check if this Node has an actual Attributes object.
|
String |
name()
Get this doctype's name (when set, or empty string)
|
String |
nodeName()
Get the node name of this node.
|
String |
publicId()
Get this doctype's Public ID (when set, or empty string)
|
Node |
removeAttr(String key)
Remove an attribute from this node.
|
void |
setPubSysKey(String value) |
String |
systemId()
Get this doctype's System ID (when set, or empty string)
|
addChildren, addChildren, after, after, attributesSize, before, before, childNode, childNodes, childNodesAsArray, childNodesCopy, clearAttributes, clone, equals, filter, hasParent, hasSameValue, html, indent, nextSibling, outerHtml, outerHtml, ownerDocument, parent, parentNode, previousSibling, remove, removeChild, reparentChild, replaceChild, replaceWith, root, setBaseUri, setParentNode, setSiblingIndex, shallowClone, siblingIndex, siblingNodes, toString, traverse, unwrap, wrap
public static final String PUBLIC_KEY
public static final String SYSTEM_KEY
public void setPubSysKey(String value)
public String name()
public String publicId()
public String systemId()
public String nodeName()
Node
protected final boolean hasAttributes()
Node
hasAttributes
in class Node
public final Attributes attributes()
Node
attributes
in class Node
public String attr(String key)
Node
To get an absolute URL from an attribute that may be a relative URL, prefix the key with abs
,
which is a shortcut to the Node.absUrl(java.lang.String)
method.
String url = a.attr("abs:href");
attr
in class Node
key
- The attribute key.Node.attributes()
,
Node.hasAttr(String)
,
Node.absUrl(String)
public Node attr(String key, String value)
Node
public boolean hasAttr(String key)
Node
public Node removeAttr(String key)
Node
removeAttr
in class Node
key
- The attribute to remove.public String absUrl(String key)
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 Node
key
- The attribute keyNode.attr(java.lang.String)
,
URL(java.net.URL, String)
public String baseUri()
Node
baseUri
in class Node
Node.absUrl(java.lang.String)
protected void doSetBaseUri(String baseUri)
Node
doSetBaseUri
in class Node
baseUri
- new URIpublic int childNodeSize()
Node
childNodeSize
in class Node
protected List<Node> ensureChildNodes()
ensureChildNodes
in class Node
Copyright © 2009–2024 Jonathan Hedley. All rights reserved.