public interface DOMNode extends DOMEventTarget, SearchContext
DOMNode
interface.
Modifier and Type | Method and Description |
---|---|
boolean |
appendChild(DOMNode childNode)
Appends a node as the last child of the current node.
将一个节点追加为当前节点的最后一个子节点。 |
void |
click()
Simulates click on the current Node.
模拟单击当前节点。 |
DOMNodePosition |
compareDocumentPosition(DOMNode targetNode)
Compares position of the current node against another node in a DOM tree.
将当前节点的位置与DOM树中的另一个节点进行比较。 |
java.util.List<DOMNode> |
getChildren()
Returns a list of child nodes of this node or empty list when this node doesn't have children.
返回此节点的子节点列表;如果此节点没有子节点,则返回空列表。 |
DOMNode |
getNextSibling()
Returns the node immediately following this one in its parent's children list, or
返回其父节点的子节点列表中紧随该节点之后的节点;如果此节点是列表中的最后一个节点,则返回null。 null if this node is the last node in the list.
|
java.lang.String |
getNodeName()
Returns the name of this node, depending on its
返回此节点的名称,具体取决于其DOMNodeType。 DOMNodeType .
|
DOMNodeType |
getNodeType()
Returns the type of this node.
返回此节点的类型。 |
java.lang.String |
getNodeValue()
Returns the value of this node, depending on its
返回此节点的值,具体取决于其DOMNodeType。 DOMNodeType .
|
DOMNode |
getParent()
Returns parent node or
返回父节点;如果没有父节点,则返回null。 null if there's no parent.
|
long |
getParentFrameId()
Returns the ID of the frame this DOMNode belongs to.
返回此DOMNode所属的帧的ID。 |
DOMNode |
getPreviousSibling()
Returns the node immediately preceding this one in its parent's children list, or
返回其父级的子级列表中紧接该节点之前的节点;如果此节点是该列表中的第一个节点,则返回null。 null if this node is the first node in that list.
|
java.lang.String |
getTextContent()
Returns text content of the node and its descendants.
返回节点及其后代的文本内容。 |
java.lang.String |
getXPath()
Returns a string that represents XPath to the current Node.
返回表示当前节点的XPath的字符串。 |
boolean |
insertChild(DOMNode node, DOMNode beforeNode)
Inserts a new
在现有的beforeNode之前插入一个新节点。 node before an existing
beforeNode .
|
boolean |
removeChild(DOMNode childNode)
Removes a child node and notifies whether child node was removed from the current node successfully or not.
删除子节点,并通知是否已成功将其从当前节点中删除。 |
boolean |
replaceChild(DOMNode newNode, DOMNode oldNode)
Replaces existing child node with a new node.
用新节点替换现有子节点。 |
void |
setNodeValue(java.lang.String value)
Sets a new node value.
设置新的节点值。 |
void |
setTextContent(java.lang.String textContent)
Updates
更新节点的textContent属性。 textContent property of the node.
|
addEventListener, dispatchEvent, getEventListeners, removeEventListener
evaluate, evaluate, findElement, findElements
java.lang.String getNodeName()
DOMNodeType
.
java.lang.String getNodeValue()
DOMNodeType
.
null
or empty string.
该节点的值。可以是或为空字符串。
void setNodeValue(java.lang.String value)
value
- the new node value.
-新的节点值。
DOMNodeType getNodeType()
DOMNode getParent()
null
if there's no parent.
java.util.List<DOMNode> getChildren()
DOMNode getNextSibling()
null
if this node is the last node in the list.
null
if this node is the last node in that list.
在其父级的子级列表中紧随其后的节点,或者该节点是该列表中的最后一个节点。
DOMNode getPreviousSibling()
null
if this node is the first node in that list.
null
if this node is the first node in that list.
在其父项的子项列表中紧接该节点之前的节点,或者如果此节点是该列表中的第一个节点。
void click()
boolean insertChild(DOMNode node, DOMNode beforeNode)
node
before an existing
beforeNode
. The new node could be an existing node in the document, or you can create and insert a new node. If the
node
is existing node, it will be moved to new location in the document.
node
- the node to insert.
-要插入的节点。
beforeNode
- the node before which the
node
will be inserted.
-将在其之前插入的节点。
true
if
node
was successfully inserted.
如果成功插入。
java.lang.IllegalArgumentException
- when
node
is
null
or
beforeNode
is
null
.
boolean replaceChild(DOMNode newNode, DOMNode oldNode)
newNode
is existing node, it will be moved to new location in the document. The old node could be used for inserting/appending it into the document later.
newNode
- the new node to replace.
-要替换的新节点。
oldNode
- the existing node, which will be replaced by
newNode
.
-现有节点,将由替换。
true
if the
oldNode
was successfully replaced with the
newNode
.
如果成功将替换为。
java.lang.IllegalArgumentException
- when
newNode
is
null
or
oldNode
is
null
.
boolean removeChild(DOMNode childNode)
childNode
- the node to remove.
-要删除的节点。
true
if the
childNode
was successfully removed.
如果成功删除了。
java.lang.IllegalArgumentException
- when
childNode
is
null
or it's not a child of the current node.
boolean appendChild(DOMNode childNode)
childNode
is existing node, it will be moved to new location in the document.
childNode
- the node to append.
-要追加的节点。
true
if the
childNode
was successfully appended.
如果成功附加。
java.lang.IllegalArgumentException
- when
childNode
is
null
.
java.lang.String getTextContent()
null
if the element is a document, a document type, or a notation. To grab all of the text and CDATA data for the whole document.
If the node is a CDATA section, a comment, a processing instruction, or a text node, this method returns the text inside this node (the
getNodeValue()
).
For other node types, this method returns the concatenation of the
textContent
attribute value of every child node, excluding comments and processing instruction nodes. This is an empty string if the node has no children.
Differences from
innerText
textContent
gets the content of all elements, including <script> and <style> elements, the mostly equivalent innerText
property, does not.innerText
is also aware of style and will not return the text of hidden elements, whereas textContent
will.innerText
is aware of CSS styling, it will trigger a reflow, whereas textContent
will not.void setTextContent(java.lang.String textContent)
textContent
property of the node. Setting this property on a node removes all of its children and replaces them with a single text node with the given value.
textContent
- content of the text node.
-文本节点的内容。
java.lang.IllegalArgumentException
- when
textContent
is
null
.
long getParentFrameId()
0
when the parent document does not belong to a frame.
此DOMNode所属的框架的ID,或者当父文档不属于框架时的ID。
java.lang.String getXPath()
null
or empty string.
表示当前节点的XPath的字符串。可以是或为空字符串。
DOMNodePosition compareDocumentPosition(DOMNode targetNode)
targetNode
-
DOMNode
to compare with.
-比较。
targetNode
against the current node.
当前节点的位置。
java.lang.IllegalArgumentException
- when
targetNode
is
null
.