Package org.jsoup.nodes
Class ProcessingInstruction
java.lang.Object
org.jsoup.nodes.Node
org.jsoup.nodes.LeafNode
org.jsoup.nodes.ProcessingInstruction
- All Implemented Interfaces:
Cloneable
A processing instruction with a target and data, such as
<?marker name="country-options"?>.
The XML declaration <?xml ...?> is represented by XmlDeclaration.
If you access this node's attributes, directly or through an attribute selector, the instruction data is parsed into an Attributes object using the owning document's parser settings, or HTML settings if the node is detached.
The attributes then determine the instruction data.
- Since:
- 1.24.1
-
Constructor Summary
ConstructorsConstructorDescriptionProcessingInstruction(String target, String data) Creates a processing instruction with the supplied target and data. -
Method Summary
Modifier and TypeMethodDescriptionStringattr(String key) Get an attribute's value by its key.attr(String key, String value) Set an attribute (key=value).intGet the number of attributes that this Node has.Clear (remove) each of the attributes in this node.clone()Create a stand-alone, deep copy of this node, and all of its children.Stringdata()Returns the data following the target.data(String data) Replaces the instruction data.StringnodeName()Returns the node name#processing-instruction.StringReturns the instruction data as this node's value.Stringtarget()Returns the instruction target.Methods inherited from class org.jsoup.nodes.LeafNode
absUrl, attributes, baseUri, childNodeSize, doClone, doSetBaseUri, empty, ensureChildNodes, hasAttr, hasAttributes, parent, removeAttrMethods inherited from class org.jsoup.nodes.Node
addChildren, addChildren, after, after, before, before, childNode, childNodes, childNodesAsArray, childNodesCopy, equals, filter, firstChild, firstSibling, forEachNode, hashCode, hasParent, hasSameValue, html, lastChild, lastSibling, nameIs, nextElementSibling, nextSibling, nodeStream, nodeStream, normalName, outerHtml, outerHtml, outerHtml, ownerDocument, parentElement, parentElementIs, parentNameIs, parentNode, previousElementSibling, previousSibling, remove, removeChild, reparentChild, replaceChild, replaceWith, root, setBaseUri, setParentNode, setSiblingIndex, shallowClone, siblingIndex, siblingNodes, sourceRange, toString, traverse, unwrap, wrapMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
Method Details
-
nodeName
public String nodeName()Returns the node name#processing-instruction. -
target
public String target()Returns the instruction target.- Returns:
- the target following
<?
-
data
public String data()Returns the data following the target. If the attributes have been accessed, returns their serialized form.- Returns:
- the instruction data
-
data
Replaces the instruction data. If the attributes have been accessed, parses the new data and updates the existingAttributesobject.- Parameters:
data- the new data, without the separating whitespace or closing?>- Returns:
- this node, for chaining
-
nodeValue
public String nodeValue()Returns the instruction data as this node's value. -
attr
public String attr(String key) Description copied from class:NodeGet 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(method.java.lang.String) String url = a.attr("abs:href"); -
attr
Description copied from class:NodeSet 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. -
attributesSize
public int attributesSize()Description copied from class:NodeGet the number of attributes that this Node has.- Overrides:
attributesSizein classNode- Returns:
- the number of attributes
-
clearAttributes
Description copied from class:NodeClear (remove) each of the attributes in this node.- Overrides:
clearAttributesin classNode- Returns:
- this, for chaining
-
clone
Description copied from class:NodeCreate a stand-alone, deep copy of this node, and all of its children. The cloned node will have no siblings.- If this node is a
LeafNode, the clone will have no parent. - If this node is an
Element, the clone will have a simple owningDocumentto retain the configured output settings and parser.
The cloned node may be adopted into another Document or node structure using
Element.appendChild(.Node) - If this node is a
-