Node Class
https://dom.spec.whatwg.org/#interface-node
public abstract class Node : EventTarget, IXPathNSResolver, IXPathNavigable- Inheritance
EventTargetNode- Implements
Properties
| Name | Description |
|---|---|
| BaseUri | https://dom.spec.whatwg.org/#dom-node-baseuri |
| ChildNodes | Gets the live list of the children of the node. |
| FirstChild | Gets the first child of the node, or null. |
| IsConnected | Gets a value indicating whether the shadow-including root of the node is a document. |
| LastChild | Gets the last child of the node, or null. |
| NextSibling | Gets the next sibling of the node, or null. |
| NodeName | Gets the name of the node, which depends on its type. |
| NodeType | Gets the type of the node, one of the node type constants. |
| NodeValue | Gets or sets the value of the node: the data of the character data nodes and attributes, null for the other nodes. |
| OwnerDocument | Gets the document that owns the node, or null when the node is a document. |
| ParentElement | Gets the parent of the node when it is an element; otherwise null. |
| ParentNode | Gets the parent of the node, or null. |
| PreviousSibling | Gets the previous sibling of the node, or null. |
| TextContent | Gets or sets the text content of the node and its descendants. |
BaseUri
Node.cshttps://dom.spec.whatwg.org/#dom-node-baseuri
public string BaseUri { get; }ChildNodes
Node.csGets the live list of the children of the node.
public NodeList ChildNodes { get; }FirstChild
Node.csGets the first child of the node, or null.
public Node? FirstChild { get; }IsConnected
Node.csGets a value indicating whether the shadow-including root of the node is a document.
public bool IsConnected { get; }LastChild
Node.csGets the last child of the node, or null.
public Node? LastChild { get; }NextSibling
Node.csGets the next sibling of the node, or null.
public Node? NextSibling { get; }NodeName
Gets the name of the node, which depends on its type.
public abstract string NodeName { get; }NodeType
Gets the type of the node, one of the node type constants.
public abstract ushort NodeType { get; }NodeValue
Node.csGets or sets the value of the node: the data of the character data nodes and attributes, null for the other nodes.
public virtual string? NodeValue { get; set; }OwnerDocument
Node.csGets the document that owns the node, or null when the node is a document.
public Document? OwnerDocument { get; }ParentElement
Node.csGets the parent of the node when it is an element; otherwise null.
public Element? ParentElement { get; }ParentNode
Node.csGets the parent of the node, or null.
public Node? ParentNode { get; }PreviousSibling
Node.csGets the previous sibling of the node, or null.
public Node? PreviousSibling { get; }TextContent
Node.csGets or sets the text content of the node and its descendants.
public virtual string? TextContent { get; set; }Methods
| Name | Description |
|---|---|
| Ancestors() | Enumerates the ancestors of this node, from the parent to the root. The enumeration is lazy and does not cross shadow roots. |
| Ancestors<T>() | Enumerates the ancestors of this node of type T, from the parent to the root. The enumeration is lazy and does not cross shadow roots. |
| AncestorsAndSelf() | Enumerates this node and its ancestors, from this node to the root (the inclusive ancestors). The enumeration is lazy and does not cross shadow roots. |
| AncestorsAndSelf<T>() | Enumerates this node and its ancestors of type T, from this node to the root. The enumeration is lazy and does not cross shadow roots. |
| AppendChild(Node) | Inserts the node after the last child and returns it. |
| CloneNode(bool) | https://dom.spec.whatwg.org/#dom-node-clonenode |
| CompareDocumentPosition(Node) | https://dom.spec.whatwg.org/#dom-node-comparedocumentposition |
| Contains(Node?) | https://dom.spec.whatwg.org/#dom-node-contains |
| CreateNavigator() | Creates a read-only XPathNavigator positioned on this node, to use the .NET XPath and XSLT APIs over the DOM (the XPath 1.0 data model: adjacent text nodes are merged, doctypes are ignored). |
| Descendants() | Enumerates the descendants of this node in tree order. The enumeration is lazy. |
| Descendants<T>() | Enumerates the descendants of this node of type T, in tree order. The enumeration is lazy. |
| DescendantsAndSelf() | Enumerates this node and its descendants in tree order (the inclusive descendants). The enumeration is lazy. |
| DescendantsAndSelf<T>() | Enumerates this node and its descendants of type T, in tree order. The enumeration is lazy. |
| GetRootNode(GetRootNodeOptions?) | Returns the root of the tree that contains the node, or its shadow-including root when composed is set. |
| HasChildNodes() | Returns whether the node has at least one child. |
| InsertBefore(Node, Node?) | Inserts the node before the given child (or after the last child when it is null) and returns it. |
| IsDefaultNamespace(string?) | https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace |
| IsEqualNode(Node?) | https://dom.spec.whatwg.org/#dom-node-isequalnode |
| IsSameNode(Node?) | Returns whether the given node is this node. |
| LookupNamespaceUri(string?) | https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri |
| LookupPrefix(string?) | https://dom.spec.whatwg.org/#dom-node-lookupprefix |
| Normalize() | https://dom.spec.whatwg.org/#dom-node-normalize |
| RemoveChild(Node) | Removes the child and returns it. |
| ReplaceChild(Node, Node) | Replaces the child with the node and returns the replaced child. |
| ToHtml(HtmlFormatter?) | Returns the markup of the node, formatted by formatter (HtmlFormatter.Default when null): an element with its start tag, its descendants and its end tag (as Element.OuterHtml), the children of a document or a document fragment. |
| ToHtml(TextWriter, HtmlFormatter?) | Same as Node.ToHtml, but writes the markup to output instead of building a string. |
Ancestors overloads
Ancestors()
Node.csEnumerates the ancestors of this node, from the parent to the root. The enumeration is lazy and does not cross shadow roots.
public IEnumerable<Node> Ancestors()Returns
Ancestors<T>()
Node.csEnumerates the ancestors of this node of type T, from the parent to the root. The enumeration is lazy and does not cross shadow roots.
public IEnumerable<T> Ancestors<T>() where T : NodeAncestorsAndSelf overloads
AncestorsAndSelf()
Node.csEnumerates this node and its ancestors, from this node to the root (the inclusive ancestors). The enumeration is lazy and does not cross shadow roots.
public IEnumerable<Node> AncestorsAndSelf()Returns
AncestorsAndSelf<T>()
Node.csEnumerates this node and its ancestors of type T, from this node to the root. The enumeration is lazy and does not cross shadow roots.
public IEnumerable<T> AncestorsAndSelf<T>() where T : NodeAppendChild(Node)
Node.csInserts the node after the last child and returns it.
CloneNode(bool)
Node.cshttps://dom.spec.whatwg.org/#dom-node-clonenode
CompareDocumentPosition(Node)
Node.cshttps://dom.spec.whatwg.org/#dom-node-comparedocumentposition
Contains(Node?)
Node.cshttps://dom.spec.whatwg.org/#dom-node-contains
Descendants overloads
Descendants()
Node.csEnumerates the descendants of this node in tree order. The enumeration is lazy.
public IEnumerable<Node> Descendants()Returns
Descendants<T>()
Node.csEnumerates the descendants of this node of type T, in tree order. The enumeration is lazy.
public IEnumerable<T> Descendants<T>() where T : NodeDescendantsAndSelf overloads
DescendantsAndSelf()
Node.csEnumerates this node and its descendants in tree order (the inclusive descendants). The enumeration is lazy.
public IEnumerable<Node> DescendantsAndSelf()Returns
DescendantsAndSelf<T>()
Node.csEnumerates this node and its descendants of type T, in tree order. The enumeration is lazy.
public IEnumerable<T> DescendantsAndSelf<T>() where T : NodeGetRootNode(GetRootNodeOptions?)
Node.csReturns the root of the tree that contains the node, or its shadow-including root when composed is set.
public Node GetRootNode(GetRootNodeOptions? options = null)HasChildNodes()
Node.csReturns whether the node has at least one child.
public bool HasChildNodes()InsertBefore(Node, Node?)
Node.csIsDefaultNamespace(string?)
Node.cshttps://dom.spec.whatwg.org/#dom-node-isdefaultnamespace
IsEqualNode(Node?)
Node.cshttps://dom.spec.whatwg.org/#dom-node-isequalnode
IsSameNode(Node?)
Node.csReturns whether the given node is this node.
LookupNamespaceUri(string?)
Node.cshttps://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
LookupPrefix(string?)
Node.cshttps://dom.spec.whatwg.org/#dom-node-lookupprefix
Normalize()
Node.cshttps://dom.spec.whatwg.org/#dom-node-normalize
public void Normalize()RemoveChild(Node)
Node.csRemoves the child and returns it.
ReplaceChild(Node, Node)
Node.csToHtml overloads
ToHtml(HtmlFormatter?)
Node.Formatting.csReturns the markup of the node, formatted by formatter (HtmlFormatter.Default when null): an element with its start tag, its descendants and its end tag (as Element.OuterHtml), the children of a document or a document fragment.
public string ToHtml(HtmlFormatter? formatter = null)ToHtml(TextWriter, HtmlFormatter?)
Node.Formatting.csSame as Node.ToHtml, but writes the markup to output instead of building a string.
public void ToHtml(TextWriter output, HtmlFormatter? formatter = null)Parameters
outputTextWriterformatterHtmlFormatter?
Constants
| Name | Description |
|---|---|
| AttributeNode | The node type of an attribute. |
| CDataSectionNode | The node type of a CDATA section. |
| CommentNode | The node type of a comment. |
| DocumentFragmentNode | The node type of a document fragment. |
| DocumentNode | The node type of a document. |
| DocumentPositionContainedBy | The bit set by compareDocumentPosition() when the other node is a descendant of the node. |
| DocumentPositionContains | The bit set by compareDocumentPosition() when the other node is an ancestor of the node. |
| DocumentPositionDisconnected | The bit set by compareDocumentPosition() when the nodes are not in the same tree. |
| DocumentPositionFollowing | The bit set by compareDocumentPosition() when the other node follows the node. |
| DocumentPositionImplementationSpecific | The bit set by compareDocumentPosition() when the order of the disconnected nodes is implementation- specific. |
| DocumentPositionPreceding | The bit set by compareDocumentPosition() when the other node precedes the node. |
| DocumentTypeNode | The node type of a document type. |
| ElementNode | The node type of an element. |
| EntityNode | The legacy node type of an entity (never created). |
| EntityReferenceNode | The legacy node type of an entity reference (never created). |
| NotationNode | The legacy node type of a notation (never created). |
| ProcessingInstructionNode | The node type of a processing instruction. |
| TextNode | The node type of a text node. |
AttributeNode
The node type of an attribute.
public const ushort AttributeNode = 2CDataSectionNode
The node type of a CDATA section.
public const ushort CDataSectionNode = 4CommentNode
The node type of a comment.
public const ushort CommentNode = 8DocumentFragmentNode
The node type of a document fragment.
public const ushort DocumentFragmentNode = 11DocumentNode
The node type of a document.
public const ushort DocumentNode = 9DocumentPositionContainedBy
The bit set by compareDocumentPosition() when the other node is a descendant of the node.
public const ushort DocumentPositionContainedBy = 16DocumentPositionContains
The bit set by compareDocumentPosition() when the other node is an ancestor of the node.
public const ushort DocumentPositionContains = 8DocumentPositionDisconnected
The bit set by compareDocumentPosition() when the nodes are not in the same tree.
public const ushort DocumentPositionDisconnected = 1DocumentPositionFollowing
The bit set by compareDocumentPosition() when the other node follows the node.
public const ushort DocumentPositionFollowing = 4DocumentPositionImplementationSpecific
The bit set by compareDocumentPosition() when the order of the disconnected nodes is implementation- specific.
public const ushort DocumentPositionImplementationSpecific = 32DocumentPositionPreceding
The bit set by compareDocumentPosition() when the other node precedes the node.
public const ushort DocumentPositionPreceding = 2DocumentTypeNode
The node type of a document type.
public const ushort DocumentTypeNode = 10ElementNode
The node type of an element.
public const ushort ElementNode = 1EntityNode
The legacy node type of an entity (never created).
public const ushort EntityNode = 6EntityReferenceNode
The legacy node type of an entity reference (never created).
public const ushort EntityReferenceNode = 5NotationNode
The legacy node type of a notation (never created).
public const ushort NotationNode = 12ProcessingInstructionNode
The node type of a processing instruction.
public const ushort ProcessingInstructionNode = 7TextNode
The node type of a text node.
public const ushort TextNode = 3