DotNetBrowser  1.14
Public Member Functions | Properties | List of all members
DotNetBrowser.DOM.DOMNode Interface Reference

Represents a singe HTML DOM node in the document tree. All JxBrowser DOM objects implement the DOMNode interface. More...

Inherits DotNetBrowser.DOM.Events.DOMEventTarget, and DotNetBrowser.DOM.SearchContext.

Inherited by DotNetBrowser.DOM.DOMElement.

Public Member Functions

List< DOMNodeGetElementsByTagName (string tagName)
 Returns a list of DOM nodes with specific tagName . More...
 
List< DOMNodeGetElementsByName (string name)
 Returns a list of DOM nodes whose name attribute is given by name . More...
 
List< DOMNodeGetElementsByClassName (string className)
 Returns a list of DOM nodes whose class attribute is given by className . More...
 
void Click ()
 Simulates click on the current Node. More...
 
DOMNode QuerySelector (string selectors)
 Returns the first DOM node from children of the current node, that match any selector within selectors string. More...
 
List< DOMNodeQuerySelectorAll (string selectors)
 Returns a list of DOM nodes from children of the current node, that match any selector within selectors string. More...
 
bool InsertChild (DOMNode node, DOMNode beforeNode)
 Inserts a new 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. More...
 
bool ReplaceChild (DOMNode newNode, DOMNode oldNode)
 Replaces existing child node with a new node. The new node could be an existing node in the document, or you can create a new node. If the 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. More...
 
bool RemoveChild (DOMNode childNode)
 Removes a child node and notifies whether child node was removed from the current node successfully or not. More...
 
bool AppendChild (DOMNode childNode)
 Appends a node as the last child of the current node. The new node could be an existing node in the document, or you can create a new node. If the childNode is existing node, it will be moved to new location in the document. More...
 
- Public Member Functions inherited from DotNetBrowser.DOM.Events.DOMEventTarget
void AddEventListener (DOMEventType eventType, DOMEventHandler handler, bool useCapture)
 This method allows the registration of event listeners on the event target. If an DOMEventHandler is added to an DOMEventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.
If multiple identical DOMEventHandlers are registered on the same DOMEventTarget with the same parameters the duplicate instances are discarded. They do not cause the DOMEventHandler to be called twice and since they are discarded they do not need to be removed with the RemoveEventListener method. More...
 
void AddEventListener (DOMEvent domEvent, DOMEventHandler handler, bool useCapture)
 This method allows the registration of event listeners on the event target. If an DOMEventHandler is added to an DOMEventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.
If multiple identical DOMEventHandlers are registered on the same DOMEventTarget with the same parameters the duplicate instances are discarded. They do not cause the DOMEventHandler to be called twice and since they are discarded they do not need to be removed with the RemoveEventListener method. More...
 
void RemoveEventListener (DOMEventType eventType, DOMEventHandler handler, bool useCapture)
 This method allows the removal of event listeners from the event target. If an DOMEventHandler is removed from an DOMEventTarget while it is processing an event, it will not be triggered by the current actions. DOMEventHandlers can never be invoked after being removed.
Calling RemoveEventListener with arguments which do not identify any currently registered DOMEventHandler on the DOMEventTarget has no effect. More...
 
void RemoveEventListener (DOMEvent domEvent, DOMEventHandler handler, bool useCapture)
 This method allows the removal of event listeners from the event target. If an DOMEventHandler is removed from an DOMEventTarget while it is processing an event, it will not be triggered by the current actions. DOMEventHandlers can never be invoked after being removed.
Calling RemoveEventListener with arguments which do not identify any currently registered DOMEventHandler on the DOMEventTarget has no effect. More...
 
List< DOMEventHandlerGetEventListeners (DOMEventType eventType)
 Returns a list of registered DOMEventHandler's for specific eventType. More...
 
List< DOMEventHandlerGetEventListeners (DOMEvent domEvent)
 Returns a list of registered DOMEventHandler's for specific custom event. More...
 
bool DispatchEvent (DOMEvent domEvent)
 Sends an event to the current element. More...
 
- Public Member Functions inherited from DotNetBrowser.DOM.SearchContext
DOMElement GetElementByTagName (string tagName)
 Finds first DOM element in the current document or element with the given tagName . Returns null if element wasn't found using given find method. More...
 
DOMElement GetElementByName (string name)
 Finds first DOM element in the current document or element with the given name . Returns null if element wasn't found using given find method. More...
 
DOMElement GetElementByClassName (string className)
 Finds first DOM element in the current document or element with the given className . Returns null if element wasn't found using given find method. More...
 
XPathResult Evaluate (string expression)
 Evaluates an XPath expression for the document element with XPathResultType.ANY_TYPE and returns the result. Equivalent of: More...
 
XPathResult Evaluate (string expression, XPathResultType type)
 Returns an XPathResult based on an XPath expression and other given parameters. More...
 

Properties

string NodeName [get]
 Gets the name of this node, depending on its DOMNodeType. More...
 
string NodeValue [get, set]
 Gets or sets the value of this node, depending on its DOMNodeType. More...
 
DOMNodeType NodeType [get]
 Gets the type of this node. More...
 
DOMNode Parent [get]
 Gets parent node or null if there's no parent. More...
 
List< DOMNodeChildren [get]
 Gets a list of child node of this node. More...
 
string XPath [get]
 Gets the xpath of this node More...
 
string TextContent [get, set]
 Gets or sets text content of the node and its descendants. More...
 
DOMNode NextSibling [get]
 Gets the node immediately following this one in its parent's children list, or null if this node is the last node in the list. More...
 
DOMNode PreviousSibling [get]
 Gets the node immediately preceding this one in its parent's children list, or null if this node is the first node in that list. More...
 

Detailed Description

Represents a singe HTML DOM node in the document tree. All JxBrowser DOM objects implement the DOMNode interface.

Member Function Documentation

bool DotNetBrowser.DOM.DOMNode.AppendChild ( DOMNode  childNode)

Appends a node as the last child of the current node. The new node could be an existing node in the document, or you can create a new node. If the childNode is existing node, it will be moved to new location in the document.

Parameters
childNodethe node to append.
Returns
true if the childNode was successfully appended.
Exceptions
ArgumentExceptionwhen childNode is null.
void DotNetBrowser.DOM.DOMNode.Click ( )

Simulates click on the current Node.

List<DOMNode> DotNetBrowser.DOM.DOMNode.GetElementsByClassName ( string  className)

Returns a list of DOM nodes whose class attribute is given by className .

Parameters
classNameclassName the class attribute value for a node.
Returns
a list of the matched DOM nodes.
Exceptions
ArgumentExceptionwhen className parameter is empty or null.
List<DOMNode> DotNetBrowser.DOM.DOMNode.GetElementsByName ( string  name)

Returns a list of DOM nodes whose name attribute is given by name .

Parameters
namethe name attribute value for a node.
Returns
a list of the matched DOM nodes.
Exceptions
ArgumentExceptionwhen name parameter is empty or null.
List<DOMNode> DotNetBrowser.DOM.DOMNode.GetElementsByTagName ( string  tagName)

Returns a list of DOM nodes with specific tagName .

Parameters
tagNamethe name of the tag to match on.
Returns
a list of the matched DOM nodes.
Exceptions
ArgumentExceptionwhen tagName parameter is empty or null.
bool DotNetBrowser.DOM.DOMNode.InsertChild ( DOMNode  node,
DOMNode  beforeNode 
)

Inserts a new 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.

Parameters
nodethe node to insert.
beforeNodethe node before which the node will be inserted.
Returns
true if node was successfully inserted.
Exceptions
ArgumentExceptionwhen node is null or beforeNode is null.
DOMNode DotNetBrowser.DOM.DOMNode.QuerySelector ( string  selectors)

Returns the first DOM node from children of the current node, that match any selector within selectors string.

Parameters
selectorsthe selectors string.
Returns
the first DOM element from children of the current element, that match any selector within selectors string or null if an element that matches the selector does not exist.
Exceptions
ArgumentExceptionif selectors parameter is null or empty.
List<DOMNode> DotNetBrowser.DOM.DOMNode.QuerySelectorAll ( string  selectors)

Returns a list of DOM nodes from children of the current node, that match any selector within selectors string.

Parameters
selectorsthe selectors string.
Returns
a list of DOM nodes from children of the current node, that match any selector within selectors string. If matches not found, returns empty list.
Exceptions
ArgumentExceptionif selectors parameter is null or empty.
bool DotNetBrowser.DOM.DOMNode.RemoveChild ( DOMNode  childNode)

Removes a child node and notifies whether child node was removed from the current node successfully or not.

Parameters
childNodethe node to remove.
Returns
true if the childNode was successfully removed.
Exceptions
ArgumentExceptionwhen childNode is null or it's not a child of the current node.
bool DotNetBrowser.DOM.DOMNode.ReplaceChild ( DOMNode  newNode,
DOMNode  oldNode 
)

Replaces existing child node with a new node. The new node could be an existing node in the document, or you can create a new node. If the 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.

Parameters
newNodethe new node to replace.
oldNodethe existing node, which will be replaced by newNode.
Returns
true if the oldNode was successfully replaced with the newNode.
Exceptions
ArgumentExceptionwhen newNode is null or oldNode is null.

Property Documentation

List<DOMNode> DotNetBrowser.DOM.DOMNode.Children
get

Gets a list of child node of this node.

DOMNode DotNetBrowser.DOM.DOMNode.NextSibling
get

Gets the node immediately following this one in its parent's children list, or null if this node is the last node in the list.

Returns
the node immediately following this one in its parent's children list, or null if this node is the last node in that list.
string DotNetBrowser.DOM.DOMNode.NodeName
get

Gets the name of this node, depending on its DOMNodeType.

the name of this node.

DOMNodeType DotNetBrowser.DOM.DOMNode.NodeType
get

Gets the type of this node.

string DotNetBrowser.DOM.DOMNode.NodeValue
getset

Gets or sets the value of this node, depending on its DOMNodeType.

the value of this node. Can be null or empty string.

DOMNode DotNetBrowser.DOM.DOMNode.Parent
get

Gets parent node or null if there's no parent.

DOMNode DotNetBrowser.DOM.DOMNode.PreviousSibling
get

Gets the node immediately preceding this one in its parent's children list, or null if this node is the first node in that list.

Returns
the node immediately preceding this one in its parent's children list, or null if this node is the first node in that list.
string DotNetBrowser.DOM.DOMNode.TextContent
getset

Gets or sets text content of the node and its descendants.

Setting this property on a node removes all of its children and replaces them with a single text node with the given value.

This method returns 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 NodeValue ).

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

  • Note that while 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.
  • As InnerText is aware of CSS styling, it will trigger a reflow, whereas TextContent will not.
Exceptions
ArgumentExceptionwhen value set null.
string DotNetBrowser.DOM.DOMNode.XPath
get

Gets the xpath of this node