Class Node
Namespace: Aspose.Html.Dom
Assembly: Aspose.HTML.dll (25.7.0)
The Node interface is the primary datatype for the entire Document object Model. It represents a single node in the document tree.
[ComVisible(true)]
[DOMObject]
[DOMName("Node")]
public abstract class Node : EventTarget, INotifyPropertyChanged, IEventTarget, IDisposable, IXPathNSResolver
Inheritance
object ← DOMObject ← EventTarget ← Node
Derived
Attr , CharacterData , Document , DocumentFragment , DocumentType , Element , Entity , EntityReference , Notation
Implements
INotifyPropertyChanged , IEventTarget , IDisposable , IXPathNSResolver
Inherited Members
EventTarget.AddEventListener(string, DOMEventHandler, bool) , EventTarget.AddEventListener(string, IEventListener) , EventTarget.AddEventListener(string, IEventListener, bool) , EventTarget.RemoveEventListener(string, DOMEventHandler, bool) , EventTarget.RemoveEventListener(string, IEventListener) , EventTarget.RemoveEventListener(string, IEventListener, bool) , EventTarget.DispatchEvent(Event) , EventTarget.Dispose() , EventTarget.Dispose(bool) , DOMObject.GetPlatformType() , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
Node(Document)
Initializes a new instance of the Aspose.Html.Dom.Node class.
protected Node(Document document)
Parameters
document
Document
The document.
Exceptions
Fields
ATTRIBUTE_NODE
An attribute node
[DOMName("ATTRIBUTE_NODE")]
public const ushort ATTRIBUTE_NODE = 2
Field Value
CDATA_SECTION_NODE
A cdata section node
[DOMName("CDATA_SECTION_NODE")]
public const ushort CDATA_SECTION_NODE = 4
Field Value
COMMENT_NODE
A comment node
[DOMName("COMMENT_NODE")]
public const ushort COMMENT_NODE = 8
Field Value
DOCUMENT_FRAGMENT_NODE
A document fragment node
[DOMName("DOCUMENT_FRAGMENT_NODE")]
public const ushort DOCUMENT_FRAGMENT_NODE = 11
Field Value
DOCUMENT_NODE
A document node
[DOMName("DOCUMENT_NODE")]
public const ushort DOCUMENT_NODE = 9
Field Value
DOCUMENT_TYPE_NODE
A document type node
[DOMName("DOCUMENT_TYPE_NODE")]
public const ushort DOCUMENT_TYPE_NODE = 10
Field Value
ELEMENT_NODE
An element node
[DOMName("ELEMENT_NODE")]
public const ushort ELEMENT_NODE = 1
Field Value
ENTITY_NODE
An entity node
[DOMName("ENTITY_NODE")]
public const ushort ENTITY_NODE = 6
Field Value
ENTITY_REFERENCE_NODE
An entity reference node
[DOMName("ENTITY_REFERENCE_NODE")]
public const ushort ENTITY_REFERENCE_NODE = 5
Field Value
NOTATION_NODE
A notation node
[DOMName("NOTATION_NODE")]
public const ushort NOTATION_NODE = 12
Field Value
PROCESSING_INSTRUCTION_NODE
A processing instruction node
[DOMName("PROCESSING_INSTRUCTION_NODE")]
public const ushort PROCESSING_INSTRUCTION_NODE = 7
Field Value
TEXT_NODE
A text node
[DOMName("TEXT_NODE")]
public const ushort TEXT_NODE = 3
Field Value
Properties
BaseURI
Returns the absolute base URL of the document containing the node.
The base URL is used to resolve relative URLs when the browser needs to obtain an absolute URL, for example when processing the HTML img element's src attribute or the xlink:href or href attributes in SVG.
[DOMName("baseURI")]
public virtual string BaseURI { get; }
Property Value
Remarks
Reference:
DOM Standard.ChildNodes
Returns a live Aspose.Html.Collections.NodeList of child nodes of the given element where the first child node is assigned index 0. Child nodes include elements, text and comments.
Note: The Aspose.Html.Collections.NodeList being live means that its content is changed each time new children are added or removed.
public NodeList ChildNodes { get; }
Property Value
Remarks
Reference:
DOM Standard.FirstChild
Returns the node's first child in the tree, or null if the node has no children.
If the node is a Document, this property returns the first node in the list of its direct children.
[DOMName("firstChild")]
public Node FirstChild { get; }
Property Value
Remarks
Reference:
DOM Standard.LastChild
Returns the last child of the node. If its parent is an element, then the child is generally an element node, a text node, or a comment node. It returns null if there are no child elements
[DOMName("lastChild")]
public Node LastChild { get; }
Property Value
Remarks
Reference:
DOM Standard.LocalName
Returns the local part of the qualified name of this node. For nodes of any type other than Aspose.Html.Dom.Node.ELEMENT_NODE and Aspose.Html.Dom.Node.ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as Aspose.Html.Dom.Document.CreateElement(System.String), this is always null.
[DOMName("localName")]
public virtual string LocalName { get; protected set; }
Property Value
Remarks
Reference:
DOM Standard.NamespaceURI
Returns the namespace URI of the element, or null if the element is not in a namespace.
[DOMName("namespaceURI")]
[DOMNullable]
public virtual string NamespaceURI { get; protected set; }
Property Value
Remarks
Reference:
DOM Standard.NextSibling
Returns the node immediately following the specified one in their parent's Aspose.Html.Dom.Node.ChildNodes, or returns null if the specified node is the last child in the parent element.
[DOMName("nextSibling")]
public Node NextSibling { get; }
Property Value
Remarks
Reference:
DOM Standard.NodeName
Returns the name of the current node as a string.
[DOMName("nodeName")]
public abstract string NodeName { get; }
Property Value
Remarks
Reference:
DOM Standard.NodeType
A code representing the type of the underlying object.
[DOMName("nodeType")]
public abstract ushort NodeType { get; }
Property Value
NodeValue
Returns or sets the value of the current node.
[DOMName("nodeValue")]
public virtual string NodeValue { get; set; }
Property Value
Remarks
Reference:
DOM Standard.OwnerDocument
Returns the top-level document object of the node.
[DOMNullable]
[DOMName("ownerDocument")]
public virtual Document OwnerDocument { get; }
Property Value
Remarks
Reference:
DOM Standard.ParentElement
Returns the DOM node's parent Aspose.Html.Dom.Element, or null if the node either has no parent, or its parent isn't a DOM Element.
[DOMNullable]
[DOMName("parentElement")]
public Element ParentElement { get; }
Property Value
Remarks
Reference:
DOM Standard.ParentNode
Returns the parent of the specified node in the DOM tree.
Aspose.Html.Dom.Document and Aspose.Html.Dom.DocumentFragment nodes can never have a parent, so ParentNode will always return null. It also returns null if the node has just been created and is not yet attached to the tree.
[DOMNullable]
[DOMName("parentNode")]
public Node ParentNode { get; }
Property Value
Remarks
Reference:
DOM Standard.Prefix
Returns the namespace prefix of the specified element, or null if no prefix is specified.
[DOMName("prefix")]
[DOMNullable]
public virtual string Prefix { get; set; }
Property Value
Remarks
Reference:
DOM Standard.PreviousSibling
Returns the node immediately preceding the specified one in its parent's Aspose.Html.Dom.Node.ChildNodes list, or null if the specified node is the first in that list.
[DOMName("previousSibling")]
public Node PreviousSibling { get; }
Property Value
Remarks
Reference:
DOM Standard.TextContent
Represents the text content of the node and its descendants.
[DOMName("textContent")]
public virtual string TextContent { get; set; }
Property Value
Remarks
Reference:
DOM Standard.Methods
AppendChild(Node)
Adds a node to the end of the list of children of a specified parent node. If the given child is a reference to an existing node in the document, Aspose.Html.Dom.Node.AppendChild(Aspose.Html.Dom.Node) moves it from its current position to the new position (there is no requirement to remove the node from its parent node before appending it to some other node).
This means that a node can't be in two points of the document simultaneously. So if the node already has a parent, the node is first removed, then appended at the new position. The Aspose.Html.Dom.Node.CloneNode method can be used to make a copy of the node before appending it under the new parent. Copies made with Aspose.Html.Dom.Node.CloneNode are not be automatically kept in sync.
[DOMName("appendChild")]
public Node AppendChild(Node node)
Parameters
node
Node
The node to append to the given parent node (commonly an element).
Returns
A Node that is the appended child, except when child is a Aspose.Html.Dom.DocumentFragment, in which case the empty Aspose.Html.Dom.DocumentFragment is returned.
Exceptions
Thrown when the constraints of the DOM tree are violated.
CloneNode()
Returns a duplicate of the node on which this method was called.
Cloning a node copies all of its attributes and their values, including intrinsic (inline) listeners. It does not copy event listeners added using Aspose.Html.Dom.Events.IEventTarget.AddEventListener(System.String,Aspose.Html.Dom.Events.IEventListener) or those assigned to element properties (e.g., node.onclick = someFunction). Additionally, for a HTMLCanvasElement element, the painted image is not copied.
[DOMName("cloneNode")]
public Node CloneNode()
Returns
The new Aspose.Html.Dom.Node cloned. The cloned node has no parent and is not part of the document, until it is added to another node that is part of the document, using Aspose.Html.Dom.Node.AppendChild(Aspose.Html.Dom.Node) or a similar method.
CloneNode(bool)
Returns a duplicate of the node on which this method was called. Its parameter controls if the subtree contained in a node is also cloned or not.
Cloning a node copies all of its attributes and their values, including intrinsic (inline) listeners. It does not copy event listeners added using Aspose.Html.Dom.Events.IEventTarget.AddEventListener(System.String,Aspose.Html.Dom.Events.IEventListener) or those assigned to element properties (e.g., node.onclick = someFunction). Additionally, for a HTMLCanvasElement element, the painted image is not copied.
[DOMName("cloneNode")]
public Node CloneNode(bool deep)
Parameters
deep
bool
If true, then the node and its whole subtree, including text that may be in child Aspose.Html.Dom.Text?text=Text nodes, is also copied.
If false, only the node will be cloned. The subtree, including any text that the node contains, is not cloned.
Note that deep has no effect on empty elements, such as the <img> and <input> elements.
Returns
The new Aspose.Html.Dom.Node cloned. The cloned node has no parent and is not part of the document, until it is added to another node that is part of the document, using Aspose.Html.Dom.Node.AppendChild(Aspose.Html.Dom.Node) or a similar method.
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)
Parameters
disposing
bool
true
to release both managed and unmanaged resources; false
to release only unmanaged resources.
~Node()
Finalizes an instance of the Aspose.Html.Dom.Node class.
protected ~Node()
HasChildNodes()
Returns a boolean value indicating whether the given Aspose.Html.Dom.Node has child nodes or not.
[DOMName("hasChildNodes")]
public bool HasChildNodes()
Returns
A boolean value that is true if the node has child nodes, and false otherwise.
InsertBefore(Node, Node)
Inserts the node before the existing child node child. If child is null, insert node at the end of the list of children. If child is a DocumentFragment object, all of its children are inserted, in the same order, before child. If the child is already in the tree, it is first removed.
[DOMName("insertBefore")]
public Node InsertBefore(Node node, Node child)
Parameters
node
Node
The new child.
child
Node
The ref child.
Returns
Returns inserted node
IsDefaultNamespace(string)
This method checks if the specified namespaceURI is the default namespace or not.
[DOMName("isDefaultNamespace")]
public bool IsDefaultNamespace(string namespaceURI)
Parameters
namespaceURI
string
The namespace URI.
Returns
true
if [is default namespace] [the specified namespace URI]; otherwise, false
.
IsEqualNode(Node)
Tests whether two nodes are equal. This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested with Node.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true.
[DOMName("isEqualNode")]
public bool IsEqualNode(Node otherNode)
Parameters
otherNode
Node
The other node.
Returns
true
if [is equal node] [the specified arg]; otherwise, false
.
IsSameNode(Node)
Method is a legacy alias the for the === strict equality operator. That is, it tests whether two nodes are the same (in other words, whether they reference the same object).
Note: There is no need to use Aspose.Html.Dom.Node.IsSameNode(Aspose.Html.Dom.Node); instead use the === strict equality operator.
[DOMName("isSameNode")]
public bool IsSameNode(Node otherNode)
Parameters
otherNode
Node
The Node to test against.
Returns
A boolean value that is true if both nodes are strictly equal, false if not.
LookupNamespaceURI(string)
Look up the namespace URI associated to the given prefix, starting from this node.
[DOMName("lookupNamespaceURI")]
public string LookupNamespaceURI(string prefix)
Parameters
prefix
string
The prefix.
Returns
Returns namespace URI
LookupPrefix(string)
Look up the prefix associated to the given namespace URI, starting from this node. The default namespace declarations are ignored by this method. See Namespace Prefix Lookup for details on the algorithm used by this method.
[DOMName("lookupPrefix")]
public string LookupPrefix(string namespaceURI)
Parameters
namespaceURI
string
The namespace URI.
Returns
Returns prefix
Normalize()
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a “normal” form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer [XPointer] lookups) that depend on a particular document tree structure are to be used. If the parameter “normalize-characters” of the DOMConfiguration object attached to the Node.ownerDocument is true, this method will also fully normalize the characters of the Text nodes.
[DOMName("normalize")]
public void Normalize()
RemoveChild(Node)
Removes a child node from the DOM and returns the removed node.
Note: As long as a reference is kept on the removed child, it still exists in memory, but is no longer part of the DOM. It can still be reused later in the code. If the return value of Aspose.Html.Dom.Node.RemoveChild(Aspose.Html.Dom.Node) is not stored, and no other reference is kept, it will be automatically deleted from memory after a short time.
[DOMName("removeChild")]
public Node RemoveChild(Node child)
Parameters
child
Node
A Aspose.Html.Dom.Node that is the child node to be removed from the DOM.
Returns
Unlike Aspose.Html.Dom.Node.CloneNode the return value preserves the Aspose.Html.Dom.Events.IEventListener?text=EventListener objects associated with it.
ReplaceChild(Node, Node)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node. If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.
[DOMName("replaceChild")]
public Node ReplaceChild(Node node, Node child)
Parameters
node
Node
The new node.
child
Node
The old child.
Returns
Returns node
ToString()
Returns a System.String that represents this instance.
public override string ToString()
Returns
A System.String that represents this instance.