Class DomNode
- All Implemented Interfaces:
Serializable,Cloneable,Node
- Direct Known Subclasses:
DomCharacterData,DomDocumentFragment,DomDocumentType,DomNamespaceNode,DomProcessingInstruction,SgmlPage
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAn iterator over all children of this node.protected final classIterates over all descendants DomTypes, in document order.protected final classIterates over all descendants DomNodes, in document order.protected classDomNode.DescendantElementsIterator<T extends DomNode>Deprecated.protected final classIterates over all descendants HtmlElements, in document order. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the "element" property.static final StringA ready state constant (state 5).static final StringA ready state constant (state 4).static final StringA ready state constant (state 3).static final StringA ready state constant (state 2).static final StringA ready state constant (state 1).Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aCharacterDataChangeListenerto the listener list.voidaddDomChangeListener(DomChangeListener listener) Adds aDomChangeListenerto the listener list.appendChild(Node node) Returns a normalized textual representation of this element that represents what would be visible to the user if this page was shown in a web browser.asXml()Returns a string representation as XML document from this element and all it's children (recursively).
The charset used in the xml header is the current page encoding; but the result is still a string.protected voidCuts off all relationships this node has with siblings and parents.protected voidcheckChildHierarchy(Node newChild) Check for insertion errors for a new child node.cloneNode(boolean deep) shortcompareDocumentPosition(Node other) protected voiddetach()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Detach this node from all relationships with other nodes.protected voidfireCharacterDataChanged(DomCharacterData characterData, String oldValue) Support for reporting Character Data changes.protected voidfireNodeAdded(DomNode parentNode, DomNode addedNode) Support for reporting DOM changes.protected voidfireNodeDeleted(DomNode parentNode, DomNode deletedNode) Support for reporting DOM changes.INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets the ancestors of the node.<T> List<T> getByXPath(String xpathExpr) Evaluates the specified XPath expression from this node, returning the matching elements.List<?> getByXPath(String xpathExpr, org.htmlunit.xpath.xml.utils.PrefixResolver resolver) Evaluates the specified XPath expression from this node, returning the matching elements.Returns the canonical XPath expression which identifies this node, for instance"/html/body/table[3]/tbody/tr[5]/td[2]/span/a[3]".Returns anIterablethat will recursively iterate over all of this node's descendants, includingDomTextelements,DomCommentelements, etc.final Iterable<DomElement> Returns anIterablethat will recursively iterate over all of this node'sDomElementdescendants.intReturns the column number in the source page where the DOM node ends.intReturns the line number in the source page where the DOM node ends.getFeature(String feature, String version) Not yet implemented.<X> XgetFirstByXPath(String xpathExpr) Evaluates the specified XPath expression from this node, returning the first matching element, ornullif no node matches the specified XPath expression.<X> XgetFirstByXPath(String xpathExpr, org.htmlunit.xpath.xml.utils.PrefixResolver resolver) Evaluates the specified XPath expression from this node, returning the first matching element, ornullif no node matches the specified XPath expression.final Iterable<HtmlElement> Returns anIterablethat will recursively iterate over all of this node'sHtmlElementdescendants.Returns the page that contains this node.intgetIndex()Returns this node's index within its parent's child nodes (zero-based).Returns the next sibling element node of this element.getPage()Returns the page that contains this node.Returns the previous sibling element node of this element.Returns this node's ready state (IE only).<T extends org.htmlunit.javascript.HtmlUnitScriptable>
TINTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.protected org.htmlunit.cssparser.parser.selector.SelectorListgetSelectorList(String selectors, WebClient webClient) Returns theSelectorList.intReturns the column number in the source page where the DOM node starts.intReturns the line number in the source page where the DOM node starts.getUserData(String key) Returns a textual representation of this element in the same way as the selenium/WebDriver WebElement#getText() property does.
see get-element-text and dfn-bot-dom-getvisibletext Note: this is different fromasNormalizedText()booleanhandles(org.htmlunit.javascript.host.event.Event event) Indicates if the provided event can be applied to this node.booleanbooleanbooleanhasFeature(BrowserVersionFeatures feature) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Helper for a common call sequence.voidinsertBefore(DomNode newNode) Inserts the specified node as a new child node before this node into the child relationship this node is a part of.insertBefore(Node newChild, Node refChild) booleanisAncestorOf(DomNode node) Returnstrueif this node is an ancestor of the specified node.booleanisAncestorOfAny(DomNode... nodes) Returnstrueif this node is an ancestor of the specified nodes.booleanINTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Indicates if this node is currently attached to the page.booleanisDefaultNamespace(String namespaceURI) Not yet implemented.booleanReturnstrueif this node is displayed and can be visible to the user (ignoring screen size, scrolling limitations, color, font-size, or overlapping nodes).booleanisEqualNode(Node arg) Not yet implemented.booleanisSameNode(Node other) booleanisSupported(String namespace, String featureName) Not yet implemented.lookupNamespaceURI(String prefix) Not yet implemented.lookupPrefix(String namespaceURI) Not yet implemented.booleanReturnstrueif nodes of this type can ever be displayed,falseotherwise.voidprotected voidnotifyIncorrectness(String message) Notifies the registeredIncorrectnessListenerof something that is not fully correct.protected voidLifecycle method invoked whenever a node is added to a document fragment.protected voidLifecycle method invoked whenever a node is added to a page.voidonAllChildrenAddedToPage(boolean postponed) Lifecycle method invoked after a node and all its children have been added to a page, during parsing of the HTML.voidparseHtmlSnippet(String source) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Parses the specified HTML source code, appending the resulting content at the specified target location.protected voidprintChildrenAsXml(String indent, PrintWriter printWriter) Recursively writes the XML data for the node tree starting atnode.protected voidprintXml(String indent, PrintWriter printWriter) Recursively writes the XML data for the node tree starting atnode.voidprocessImportNode(org.htmlunit.javascript.host.dom.Document doc) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Lifecycle method to support special processing for js method importNode.<N extends DomNode>
NquerySelector(String selectors) Returns the first element within the document that matches the specified group of selectors.querySelectorAll(String selectors) Retrieves all element nodes from descendants of the starting element node that match any selector within the supplied selector strings.voidquietlyRemoveAndMoveChildrenTo(DomNode destination) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Quietly removes this node and moves its children to the specified destination.voidremove()Removes this node from all relationships with other nodes.voidRemoves all of this node's children.voidRemoves aCharacterDataChangeListenerfrom the listener list.removeChild(Node child) voidremoveDomChangeListener(DomChangeListener listener) Removes aDomChangeListenerfrom the listener list.voidReplaces this node with another node.replaceChild(Node newChild, Node oldChild) voidsetEndLocation(int endLineNumber, int endColumnNumber) Sets the line and column numbers in the source page where the DOM node ends.protected voidsetParentNode(DomNode parent) Sets the parent node.voidsetReadyState(String state) Sets this node's ready state (IE only).voidsetScriptableObject(org.htmlunit.javascript.HtmlUnitScriptable scriptObject) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the JavaScript object that corresponds to this node.voidsetStartLocation(int startLineNumber, int startColumnNumber) Sets the line and column numbers in the source page where the DOM node starts.voidsetTextContent(String textContent) setUserData(String key, Object data, UserDataHandler handler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.w3c.dom.Node
getNodeName, getNodeType, setNodeValue, setPrefix
-
Field Details
-
READY_STATE_UNINITIALIZED
A ready state constant (state 1).- See Also:
-
READY_STATE_LOADING
A ready state constant (state 2).- See Also:
-
READY_STATE_LOADED
A ready state constant (state 3).- See Also:
-
READY_STATE_INTERACTIVE
A ready state constant (state 4).- See Also:
-
READY_STATE_COMPLETE
A ready state constant (state 5).- See Also:
-
PROPERTY_ELEMENT
The name of the "element" property. Used when watching property change events.- See Also:
-
-
Constructor Details
-
DomNode
Creates a new instance.- Parameters:
page- the page which contains this node
-
-
Method Details
-
setStartLocation
public void setStartLocation(int startLineNumber, int startColumnNumber) Sets the line and column numbers in the source page where the DOM node starts.- Parameters:
startLineNumber- the line number where the DOM node startsstartColumnNumber- the column number where the DOM node starts
-
setEndLocation
public void setEndLocation(int endLineNumber, int endColumnNumber) Sets the line and column numbers in the source page where the DOM node ends.- Parameters:
endLineNumber- the line number where the DOM node endsendColumnNumber- the column number where the DOM node ends
-
getStartLineNumber
public int getStartLineNumber()Returns the line number in the source page where the DOM node starts.- Returns:
- the line number in the source page where the DOM node starts
-
getStartColumnNumber
public int getStartColumnNumber()Returns the column number in the source page where the DOM node starts.- Returns:
- the column number in the source page where the DOM node starts
-
getEndLineNumber
public int getEndLineNumber()Returns the line number in the source page where the DOM node ends.- Returns:
- 0 if no information on the line number is available (for instance for nodes dynamically added), -1 if the end tag has not yet been parsed (during page loading)
-
getEndColumnNumber
public int getEndColumnNumber()Returns the column number in the source page where the DOM node ends.- Returns:
- 0 if no information on the line number is available (for instance for nodes dynamically added), -1 if the end tag has not yet been parsed (during page loading)
-
getPage
Returns the page that contains this node.- Returns:
- the page that contains this node
-
getHtmlPageOrNull
Returns the page that contains this node.- Returns:
- the page that contains this node
-
getOwnerDocument
- Specified by:
getOwnerDocumentin interfaceNode
-
setScriptableObject
public void setScriptableObject(org.htmlunit.javascript.HtmlUnitScriptable scriptObject) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the JavaScript object that corresponds to this node. This is not guaranteed to be set even if there is a JavaScript object for this DOM node.- Parameters:
scriptObject- the JavaScript object
-
getLastChild
- Specified by:
getLastChildin interfaceNode
-
getParentNode
- Specified by:
getParentNodein interfaceNode
-
setParentNode
Sets the parent node.- Parameters:
parent- the parent node
-
getIndex
public int getIndex()Returns this node's index within its parent's child nodes (zero-based).- Returns:
- this node's index within its parent's child nodes (zero-based)
-
getPreviousSibling
- Specified by:
getPreviousSiblingin interfaceNode
-
getNextSibling
- Specified by:
getNextSiblingin interfaceNode
-
getFirstChild
- Specified by:
getFirstChildin interfaceNode
-
isAncestorOf
Returnstrueif this node is an ancestor of the specified node.- Parameters:
node- the node to check- Returns:
trueif this node is an ancestor of the specified node
-
isAncestorOfAny
Returnstrueif this node is an ancestor of the specified nodes.- Parameters:
nodes- the nodes to check- Returns:
trueif this node is an ancestor of the specified nodes
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceNode
-
getLocalName
- Specified by:
getLocalNamein interfaceNode
-
getPrefix
-
hasChildNodes
public boolean hasChildNodes()- Specified by:
hasChildNodesin interfaceNode
-
getChildNodes
- Specified by:
getChildNodesin interfaceNode
-
isSupported
Not yet implemented.- Specified by:
isSupportedin interfaceNode
-
normalize
public void normalize() -
getBaseURI
- Specified by:
getBaseURIin interfaceNode
-
compareDocumentPosition
- Specified by:
compareDocumentPositionin interfaceNode
-
getAncestors
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets the ancestors of the node.- Returns:
- a list of the ancestors with the root at the first position
-
getTextContent
- Specified by:
getTextContentin interfaceNode
-
setTextContent
- Specified by:
setTextContentin interfaceNode
-
isSameNode
- Specified by:
isSameNodein interfaceNode
-
lookupPrefix
Not yet implemented.- Specified by:
lookupPrefixin interfaceNode
-
isDefaultNamespace
Not yet implemented.- Specified by:
isDefaultNamespacein interfaceNode
-
lookupNamespaceURI
Not yet implemented.- Specified by:
lookupNamespaceURIin interfaceNode
-
isEqualNode
Not yet implemented.- Specified by:
isEqualNodein interfaceNode
-
getFeature
Not yet implemented.- Specified by:
getFeaturein interfaceNode
-
getUserData
- Specified by:
getUserDatain interfaceNode
-
setUserData
- Specified by:
setUserDatain interfaceNode
-
hasAttributes
public boolean hasAttributes()- Specified by:
hasAttributesin interfaceNode
-
getAttributes
- Specified by:
getAttributesin interfaceNode
-
isDisplayed
public boolean isDisplayed()Returns
trueif this node is displayed and can be visible to the user (ignoring screen size, scrolling limitations, color, font-size, or overlapping nodes).NOTE: If CSS is
disabled, this method does not take this element's style into consideration!- Returns:
trueif the node is visible to the user,falseotherwise- See Also:
-
mayBeDisplayed
public boolean mayBeDisplayed()Returnstrueif nodes of this type can ever be displayed,falseotherwise. Examples of nodes that can never be displayed are<head>,<meta>,<script>, etc.- Returns:
trueif nodes of this type can ever be displayed,falseotherwise- See Also:
-
asNormalizedText
Returns a normalized textual representation of this element that represents what would be visible to the user if this page was shown in a web browser. Whitespace is normalized like in the browser and block tags are separated by '\n'.- Returns:
- a normalized textual representation of this element
-
getVisibleText
Returns a textual representation of this element in the same way as the selenium/WebDriver WebElement#getText() property does.
see get-element-text and dfn-bot-dom-getvisibletext Note: this is different fromasNormalizedText()- Returns:
- a textual representation of this element that represents what would be visible to the user if this page was shown in a web browser
-
asXml
Returns a string representation as XML document from this element and all it's children (recursively).
The charset used in the xml header is the current page encoding; but the result is still a string. You have to make sure to use the correct (in fact the same) encoding if you write this to a file.
This serializes the current state of the DomTree - this implies that the content of noscript tags usually serialized as string because the content is converted during parsing (if js was enabled at that time).- Returns:
- the XML string
-
printXml
Recursively writes the XML data for the node tree starting atnode.- Parameters:
indent- white space to indent child nodesprintWriter- writer where child nodes are written
-
printChildrenAsXml
Recursively writes the XML data for the node tree starting atnode.- Parameters:
indent- white space to indent child nodesprintWriter- writer where child nodes are written
-
getNodeValue
- Specified by:
getNodeValuein interfaceNode
-
cloneNode
-
getScriptableObject
public <T extends org.htmlunit.javascript.HtmlUnitScriptable> T getScriptableObject()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the JavaScript object that corresponds to this node, lazily initializing a new one if necessary.
The logic of when and where the JavaScript object is created needs a clean up: functions using a DOM node's JavaScript object should not have to check if they should create it first.
- Type Parameters:
T- the object type- Returns:
- the JavaScript object that corresponds to this node
-
appendChild
- Specified by:
appendChildin interfaceNode
-
insertBefore
- Specified by:
insertBeforein interfaceNode
-
insertBefore
Inserts the specified node as a new child node before this node into the child relationship this node is a part of. If the specified node is this node, this method is a no-op.- Parameters:
newNode- the new node to insert
-
removeChild
- Specified by:
removeChildin interfaceNode
-
removeAllChildren
public void removeAllChildren()Removes all of this node's children. -
parseHtmlSnippet
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Parses the specified HTML source code, appending the resulting content at the specified target location.- Parameters:
source- the HTML code extract to parse- Throws:
IOException- in case of errorSAXException- in case of error
-
remove
public void remove()Removes this node from all relationships with other nodes. -
detach
protected void detach()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Detach this node from all relationships with other nodes. This is the first step of a move. -
basicRemove
protected void basicRemove()Cuts off all relationships this node has with siblings and parents. -
replaceChild
- Specified by:
replaceChildin interfaceNode
-
replace
Replaces this node with another node. If the specified node is this node, this method is a no-op.- Parameters:
newNode- the node to replace this one
-
quietlyRemoveAndMoveChildrenTo
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Quietly removes this node and moves its children to the specified destination. "Quietly" means that no node events are fired. This method is not appropriate for most use cases. It should only be used in specific cases for HTML parsing hackery.- Parameters:
destination- the node to which this node's children should be moved before this node is removed
-
checkChildHierarchy
Check for insertion errors for a new child node. This is overridden by derived classes to enforce which types of children are allowed.- Parameters:
newChild- the new child node that is being inserted below this node- Throws:
DOMException- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to insert is one of this node's ancestors or this node itself, or if this node is of type Document and the DOM application attempts to insert a second DocumentType or Element node. WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
-
onAddedToPage
protected void onAddedToPage()Lifecycle method invoked whenever a node is added to a page. Intended to be overridden by nodes which need to perform custom logic when they are added to a page. This method is recursive, so if you override it, please be sure to callsuper.onAddedToPage(). -
onAllChildrenAddedToPage
public void onAllChildrenAddedToPage(boolean postponed) Lifecycle method invoked after a node and all its children have been added to a page, during parsing of the HTML. Intended to be overridden by nodes which need to perform custom logic after they and all their child nodes have been processed by the HTML parser. This method is not recursive, and the default implementation is empty, so there is no need to callsuper.onAllChildrenAddedToPage()if you implement this method.- Parameters:
postponed- whether to usePostponedActionor no
-
onAddedToDocumentFragment
protected void onAddedToDocumentFragment()Lifecycle method invoked whenever a node is added to a document fragment. Intended to be overridden by nodes which need to perform custom logic when they are added to a fragment. This method is recursive, so if you override it, please be sure to callsuper.onAddedToDocumentFragment(). -
getChildren
- Returns:
- an
Iterableover the children of this node
-
getDescendants
Returns anIterablethat will recursively iterate over all of this node's descendants, includingDomTextelements,DomCommentelements, etc. If you want to iterate only overHtmlElementdescendants, please usegetHtmlElementDescendants().- Returns:
- an
Iterablethat will recursively iterate over all of this node's descendants
-
getHtmlElementDescendants
Returns anIterablethat will recursively iterate over all of this node'sHtmlElementdescendants. If you want to iterate over all descendants (includingDomTextelements,DomCommentelements, etc.), please usegetDescendants().- Returns:
- an
Iterablethat will recursively iterate over all of this node'sHtmlElementdescendants - See Also:
-
getDomElementDescendants
Returns anIterablethat will recursively iterate over all of this node'sDomElementdescendants. If you want to iterate over all descendants (includingDomTextelements,DomCommentelements, etc.), please usegetDescendants().- Returns:
- an
Iterablethat will recursively iterate over all of this node'sDomElementdescendants - See Also:
-
getReadyState
Returns this node's ready state (IE only).- Returns:
- this node's ready state
-
setReadyState
Sets this node's ready state (IE only).- Parameters:
state- this node's ready state
-
getByXPath
Evaluates the specified XPath expression from this node, returning the matching elements.
Note: This implies that the ',' point to this node but the general axis like '//' are still looking at the whole document. E.g. if you like to get all child h1 nodes from the current one you have to use './/h1' instead of '//h1' because the latter matches all h1 nodes of the# whole document.- Type Parameters:
T- the expected type- Parameters:
xpathExpr- the XPath expression to evaluate- Returns:
- the elements which match the specified XPath expression
- See Also:
-
getByXPath
Evaluates the specified XPath expression from this node, returning the matching elements.- Parameters:
xpathExpr- the XPath expression to evaluateresolver- the prefix resolver to use for resolving namespace prefixes, or null- Returns:
- the elements which match the specified XPath expression
- See Also:
-
getFirstByXPath
Evaluates the specified XPath expression from this node, returning the first matching element, ornullif no node matches the specified XPath expression.- Type Parameters:
X- the expression type- Parameters:
xpathExpr- the XPath expression- Returns:
- the first element matching the specified XPath expression
- See Also:
-
getFirstByXPath
public <X> X getFirstByXPath(String xpathExpr, org.htmlunit.xpath.xml.utils.PrefixResolver resolver) Evaluates the specified XPath expression from this node, returning the first matching element, ornullif no node matches the specified XPath expression.- Type Parameters:
X- the expression type- Parameters:
xpathExpr- the XPath expressionresolver- the prefix resolver to use for resolving namespace prefixes, or null- Returns:
- the first element matching the specified XPath expression
- See Also:
-
getCanonicalXPath
Returns the canonical XPath expression which identifies this node, for instance
"/html/body/table[3]/tbody/tr[5]/td[2]/span/a[3]".WARNING: This sort of automated XPath expression is often quite bad at identifying a node, as it is highly sensitive to changes in the DOM tree.
- Returns:
- the canonical XPath expression which identifies this node
- See Also:
-
notifyIncorrectness
Notifies the registeredIncorrectnessListenerof something that is not fully correct.- Parameters:
message- the notification to send to the registeredIncorrectnessListener
-
addDomChangeListener
Adds aDomChangeListenerto the listener list. The listener is registered for all descendants of this node.- Parameters:
listener- the DOM structure change listener to be added- See Also:
-
removeDomChangeListener
Removes aDomChangeListenerfrom the listener list. The listener is deregistered for all descendants of this node.- Parameters:
listener- the DOM structure change listener to be removed- See Also:
-
fireNodeAdded
Support for reporting DOM changes. This method can be called when a node has been added, and it will send the appropriateDomChangeEventto any registeredDomChangeListeners.Note that this method recursively calls this node's parent's
fireNodeAdded(DomNode, DomNode).- Parameters:
parentNode- the parent of the node that was changedaddedNode- the node that has been added
-
addCharacterDataChangeListener
Adds aCharacterDataChangeListenerto the listener list. The listener is registered for all descendants of this node.- Parameters:
listener- the character data change listener to be added- See Also:
-
removeCharacterDataChangeListener
Removes aCharacterDataChangeListenerfrom the listener list. The listener is deregistered for all descendants of this node.- Parameters:
listener- the Character Data change listener to be removed- See Also:
-
fireCharacterDataChanged
Support for reporting Character Data changes.Note that this method recursively calls this node's parent's
fireCharacterDataChanged(org.htmlunit.html.DomCharacterData, java.lang.String).- Parameters:
characterData- the character data which is changedoldValue- the old value
-
fireNodeDeleted
Support for reporting DOM changes. This method can be called when a node has been deleted, and it will send the appropriateDomChangeEventto any registeredDomChangeListeners.Note that this method recursively calls this node's parent's
fireNodeDeleted(DomNode, DomNode).- Parameters:
parentNode- the parent of the node that was changeddeletedNode- the node that has been deleted
-
querySelectorAll
Retrieves all element nodes from descendants of the starting element node that match any selector within the supplied selector strings.- Parameters:
selectors- one or more CSS selectors separated by commas- Returns:
- list of all found nodes
-
getSelectorList
protected org.htmlunit.cssparser.parser.selector.SelectorList getSelectorList(String selectors, WebClient webClient) throws IOException Returns theSelectorList.- Parameters:
selectors- the selectorswebClient- theWebClient- Returns:
- the
SelectorList - Throws:
IOException- if an error occurs
-
querySelector
Returns the first element within the document that matches the specified group of selectors.- Type Parameters:
N- the node type- Parameters:
selectors- one or more CSS selectors separated by commas- Returns:
- null if no matches are found; otherwise, it returns the first matching element
-
isAttachedToPage
public boolean isAttachedToPage()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Indicates if this node is currently attached to the page.- Returns:
trueif the page is one ancestor of the node.
-
processImportNode
public void processImportNode(org.htmlunit.javascript.host.dom.Document doc) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Lifecycle method to support special processing for js method importNode.- Parameters:
doc- the import target document- See Also:
-
hasFeature
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Helper for a common call sequence.- Parameters:
feature- the feature to check- Returns:
trueif the currently emulated browser has this feature.
-
handles
public boolean handles(org.htmlunit.javascript.host.event.Event event) Indicates if the provided event can be applied to this node. Overwrite this.- Parameters:
event- the event- Returns:
falseif the event can't be applied
-
getPreviousElementSibling
Returns the previous sibling element node of this element. null if this element has no element sibling nodes that come before this one in the document tree.- Returns:
- the previous sibling element node of this element. null if this element has no element sibling nodes that come before this one in the document tree
-
getNextElementSibling
Returns the next sibling element node of this element. null if this element has no element sibling nodes that come after this one in the document tree.- Returns:
- the next sibling element node of this element. null if this element has no element sibling nodes that come after this one in the document tree
-
closest
- Parameters:
selectorString- the selector to test- Returns:
- the selected
DomElementor null.
-
DomNode.DescendantDomNodesIterator,DomNode.DescendantDomElementsIterator, orDomNode.DescendantHtmlElementsIteratorinstead.