Package org.jsoup.nodes
Class DocumentType
java.lang.Object
org.jsoup.nodes.Node
org.jsoup.nodes.DocumentType
- All Implemented Interfaces:
Cloneable
A
<!DOCTYPE>
node.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDocumentType
(String name, String publicId, String systemId) Create a new doctype element. -
Method Summary
Modifier and TypeMethodDescriptionGet an absolute URL from a URL attribute that may be relative (such as an<a href>
or<img src>
).Get an attribute's value by its key.Set an attribute (key=value).final Attributes
Get all of the element's attributes.baseUri()
Get the base URI that applies to this node.int
Get the number of child nodes that this node holds.protected org.jsoup.nodes.LeafNode
protected void
doSetBaseUri
(String baseUri) Set the baseUri for just this node (not its descendants), if this Node tracks base URIs.empty()
Delete all this node's children.boolean
Test if this Node has an attribute.protected final boolean
Check if this Node has an actual Attributes object.name()
Get this doctype's name (when set, or empty string)nodeName()
Get the node name of this node.publicId()
Get this doctype's Public ID (when set, or empty string)removeAttr
(String key) Remove an attribute from this node.void
setPubSysKey
(String value) systemId()
Get this doctype's System ID (when set, or empty string)Methods inherited from class org.jsoup.nodes.Node
addChildren, addChildren, after, after, attributesSize, before, before, childNode, childNodes, childNodesAsArray, childNodesCopy, clearAttributes, clone, equals, filter, firstChild, forEachNode, hashCode, hasParent, hasSameValue, html, indent, lastChild, nextSibling, outerHtml, outerHtml, ownerDocument, parent, parentNode, previousSibling, remove, removeChild, reparentChild, replaceChild, replaceWith, root, setBaseUri, setParentNode, setSiblingIndex, shallowClone, siblingIndex, siblingNodes, sourceRange, toString, traverse, unwrap, wrap
-
Field Details
-
PUBLIC_KEY
- See Also:
-
SYSTEM_KEY
- See Also:
-
-
Constructor Details
-
DocumentType
Create a new doctype element.- Parameters:
name
- the doctype's namepublicId
- the doctype's public IDsystemId
- the doctype's system ID
-
-
Method Details
-
setPubSysKey
-
name
Get this doctype's name (when set, or empty string)- Returns:
- doctype name
-
publicId
Get this doctype's Public ID (when set, or empty string)- Returns:
- doctype Public ID
-
systemId
Get this doctype's System ID (when set, or empty string)- Returns:
- doctype System ID
-
nodeName
Description copied from class:Node
Get the node name of this node. Use for debugging purposes and not logic switching (for that, use instanceof). -
hasAttributes
protected final boolean hasAttributes()Description copied from class:Node
Check if this Node has an actual Attributes object.- Specified by:
hasAttributes
in classNode
-
attributes
Description copied from class:Node
Get all of the element's attributes.- Specified by:
attributes
in classNode
- Returns:
- attributes (which implements iterable, in same order as presented in original HTML).
-
attr
Description copied from class:Node
Get an attribute's value by its key. Case insensitiveTo get an absolute URL from an attribute that may be a relative URL, prefix the key with
E.g.:abs
, which is a shortcut to theNode.absUrl(java.lang.String)
method.String url = a.attr("abs:href");
-
attr
Description copied from class:Node
Set an attribute (key=value). If the attribute already exists, it is replaced. The attribute key comparison is case insensitive. The key will be set with case sensitivity as set in the parser settings. -
hasAttr
Description copied from class:Node
Test if this Node has an attribute. Case insensitive. -
removeAttr
Description copied from class:Node
Remove an attribute from this node.- Overrides:
removeAttr
in classNode
- Parameters:
key
- The attribute to remove.- Returns:
- this (for chaining)
-
absUrl
Description copied from class:Node
Get an absolute URL from a URL attribute that may be relative (such as an<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://
orhttps://
etc), and it successfully parses as a URL, the attribute is returned directly. Otherwise, it is treated as a URL relative to the element'sNode.baseUri()
, and made absolute using that.As an alternate, you can use the
Node.attr(java.lang.String)
method with theabs:
prefix, e.g.:String absUrl = linkEl.attr("abs:href");
-
baseUri
Description copied from class:Node
Get the base URI that applies to this node. Will return an empty string if not defined. Used to make relative links absolute. -
doSetBaseUri
Description copied from class:Node
Set the baseUri for just this node (not its descendants), if this Node tracks base URIs.- Specified by:
doSetBaseUri
in classNode
- Parameters:
baseUri
- new URI
-
childNodeSize
public int childNodeSize()Description copied from class:Node
Get the number of child nodes that this node holds.- Specified by:
childNodeSize
in classNode
- Returns:
- the number of child nodes that this node holds.
-
empty
Description copied from class:Node
Delete all this node's children. -
ensureChildNodes
- Specified by:
ensureChildNodes
in classNode
-
doClone
-