Table of Contents

Interface INode

Namespace
AngleSharp.Dom
Assembly
AngleSharp.dll

A Node is an interface from which a number of DOM types inherit, and allows these various types to be treated similarly.

[DomName("Node")]
public interface INode : IEventTarget, IMarkupFormattable
Inherited Members
Extension Methods

Properties

BaseUri

Gets a string representing the base URL.

[DomName("baseURI")]
string BaseUri { get; }

Property Value

string

BaseUrl

Gets the base url.

Url? BaseUrl { get; }

Property Value

Url

ChildNodes

Gets a live NodeList containing all the children of this node. Being live means that if the children of the node change, the NodeList object is automatically updated.

[DomName("childNodes")]
INodeList ChildNodes { get; }

Property Value

INodeList

FirstChild

Gets a Node representing the first direct child node of the node, or null if the node has no child.

[DomName("firstChild")]
INode? FirstChild { get; }

Property Value

INode

Flags

Gets the associated node flags.

NodeFlags Flags { get; }

Property Value

NodeFlags

HasChildNodes

Gets an indicator if the element has any child nodes, or not.

[DomName("hasChildNodes")]
bool HasChildNodes { get; }

Property Value

bool

LastChild

Gets a node representing the last direct child node of the node, or null if the node has no child.

[DomName("lastChild")]
INode? LastChild { get; }

Property Value

INode

NextSibling

Gets a Node representing the next node in the tree, or null if there isn't such node.

[DomName("nextSibling")]
INode? NextSibling { get; }

Property Value

INode

NodeName

Gets a string containing the name of the Node. The structure of the name will differ with the name type.

[DomName("nodeName")]
string NodeName { get; }

Property Value

string

NodeType

Gets an unsigned short representing the type of the node.

[DomName("nodeType")]
NodeType NodeType { get; }

Property Value

NodeType

NodeValue

Gets or sets a string representing the value of an object. For most node types, this returns null and any set operation is ignored.

[DomName("nodeValue")]
string NodeValue { get; set; }

Property Value

string

Owner

Gets the Document that this node belongs to. If no document is associated with it, returns null.

[DomName("ownerDocument")]
IDocument? Owner { get; }

Property Value

IDocument

Parent

Gets a node that is the parent of this node. If there is no such node, like if this node is the top of the tree or if doesn't participate in a tree, this property returns null.

[DomName("parentNode")]
INode? Parent { get; }

Property Value

INode

ParentElement

Gets an Element that is the parent of this node. If the node has no parent, or if that parent is not an Element, this property returns null.

[DomName("parentElement")]
IElement? ParentElement { get; }

Property Value

IElement

PreviousSibling

Gets a Node representing the previous node in the tree, or null if there isn't such node.

[DomName("previousSibling")]
INode? PreviousSibling { get; }

Property Value

INode

TextContent

Gets or sets the textual content of an element and all its descendants.

[DomName("textContent")]
string TextContent { get; set; }

Property Value

string

Methods

AppendChild(INode)

Inserts a node as the last child node of this element.

[DomName("appendChild")]
INode AppendChild(INode child)

Parameters

child INode

The node to be appended.

Returns

INode

The appended Node.

Clone(bool)

Clones the node, and optionally, all of its contents. By default, it clones the content of the node.

[DomName("cloneNode")]
INode Clone(bool deep = true)

Parameters

deep bool

Optionally: Sets if all of the content should be cloned as well.

Returns

INode

The cloned node.

CompareDocumentPosition(INode)

Compares the position of two nodes in a document.

[DomName("compareDocumentPosition")]
DocumentPositions CompareDocumentPosition(INode otherNode)

Parameters

otherNode INode

The node to be compared to the reference node, which is the node executing the method.

Returns

DocumentPositions

The relation between the two nodes.

Contains(INode)

Returns true if other is an inclusive descendant of the context object, and false otherwise (including when other is null).

[DomName("contains")]
bool Contains(INode otherNode)

Parameters

otherNode INode

The Node to check the childs for.

Returns

bool

True if the given node is contained within this Node, otherwise false.

Equals(INode)

Determines if two nodes are equal.

[DomName("isEqualNode")]
bool Equals(INode otherNode)

Parameters

otherNode INode

The node to be compared to the node that is executing the method.

Returns

bool

True if the node specified in the otherNode parameter is equal to the current node.

InsertBefore(INode, INode?)

Inserts the newElement immediately before the referenceElement.

[DomName("insertBefore")]
INode InsertBefore(INode newElement, INode? referenceElement)

Parameters

newElement INode

The node to be inserted.

referenceElement INode

The existing child element that will succeed the new element.

Returns

INode

The inserted node.

IsDefaultNamespace(string)

Indicates whether or not a namespace is the default namespace for a document.

[DomName("isDefaultNamespace")]
bool IsDefaultNamespace(string namespaceUri)

Parameters

namespaceUri string

The namespace to be compared to the default namespace.

Returns

bool

True if the given namespace URI is the default for the current document.

LookupNamespaceUri(string)

Gets the Uniform Resource Identifier (URI) of the namespace associated with a namespace prefix, if any.

[DomName("lookupNamespaceURI")]
string? LookupNamespaceUri(string prefix)

Parameters

prefix string

The namespace prefix.

Returns

string

The URI of the namespace.

LookupPrefix(string?)

Gets the namespace prefix associated with a Uniform Resource Identifier (URI), if any.

[DomName("lookupPrefix")]
string? LookupPrefix(string? namespaceUri)

Parameters

namespaceUri string

The URI.

Returns

string

The namespace prefix associated with the URI.

Normalize()

Cleans up all the text nodes under this element, i.e. merges adjacent and removes empty text nodes.

[DomName("normalize")]
void Normalize()

RemoveChild(INode)

Removes a child node from the current element, which must be a child of the current node.

[DomName("removeChild")]
INode RemoveChild(INode child)

Parameters

child INode

The child to be removed.

Returns

INode

The removed node.

ReplaceChild(INode, INode)

Replaces one child node of the current one with the second one given in the parameters.

[DomName("replaceChild")]
INode ReplaceChild(INode newChild, INode oldChild)

Parameters

newChild INode

The child to be inserted.

oldChild INode

The child to be removed.

Returns

INode

The old node, if any.