Table of Contents

Class Node

Namespace
AngleSharp.Dom
Assembly
AngleSharp.dll

Represents a node in the generated tree.

public abstract class Node : EventTarget, INode, IEventTarget, IMarkupFormattable, IEquatable<INode>
Inheritance
Node
Implements
Derived
Inherited Members
Extension Methods

Constructors

Node(Document?, string, NodeType, NodeFlags)

public Node(Document? owner, string name, NodeType type = NodeType.Element, NodeFlags flags = NodeFlags.None)

Parameters

owner Document
name string
type NodeType
flags NodeFlags

Properties

BaseUri

Gets a string representing the base URL.

public string BaseUri { get; }

Property Value

string

BaseUrl

Gets the base url.

public Url? BaseUrl { get; set; }

Property Value

Url

Flags

Gets the associated node flags.

public NodeFlags Flags { get; }

Property Value

NodeFlags

HasChildNodes

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

public bool HasChildNodes { get; }

Property Value

bool

NodeName

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

public string NodeName { get; }

Property Value

string

NodeType

Gets an unsigned short representing the type of the node.

public 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.

public virtual string NodeValue { get; set; }

Property Value

string

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.

public IElement? ParentElement { get; }

Property Value

IElement

TextContent

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

public virtual string TextContent { get; set; }

Property Value

string

Methods

AddNode(Node)

public void AddNode(Node node)

Parameters

node Node

AppendChild(INode)

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

public INode AppendChild(INode child)

Parameters

child INode

The node to be appended.

Returns

INode

The appended Node.

AppendText(string)

public void AppendText(string s)

Parameters

s string

Clone(Document, bool)

Clones the current node using the new owner.

public abstract Node Clone(Document newOwner, bool deep)

Parameters

newOwner Document

The new document owner, if any.

deep bool

True if a deep clone is wanted, otherwise false.

Returns

Node

The cloned node.

Clone(bool)

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

public 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.

CloneNode(Node, Document, bool)

protected void CloneNode(Node target, Document owner, bool deep)

Parameters

target Node
owner Document
deep bool

CompareDocumentPosition(INode)

Compares the position of two nodes in a document.

public 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).

public 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?)

public virtual bool Equals(INode? otherNode)

Parameters

otherNode INode

Returns

bool

GetPrefixAndLocalName(string, ref string?, out string?, out string)

protected static void GetPrefixAndLocalName(string qualifiedName, ref string? namespaceUri, out string? prefix, out string localName)

Parameters

qualifiedName string
namespaceUri string
prefix string
localName string

InsertBefore(INode, INode?)

Inserts the newElement immediately before the referenceElement.

public 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.

InsertChild(int, INode)

public INode InsertChild(int index, INode child)

Parameters

index int
child INode

Returns

INode

InsertNode(int, Node)

public void InsertNode(int index, Node node)

Parameters

index int
node Node

InsertText(int, string)

public void InsertText(int index, string s)

Parameters

index int
s string

IsDefaultNamespace(string?)

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

public 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.

IsNamespaceError(string?, string?, string)

protected static bool IsNamespaceError(string? prefix, string? namespaceUri, string qualifiedName)

Parameters

prefix string
namespaceUri string
qualifiedName string

Returns

bool

LocateNamespace(string)

protected virtual string? LocateNamespace(string prefix)

Parameters

prefix string

Returns

string

LocatePrefix(string)

protected virtual string? LocatePrefix(string namespaceUri)

Parameters

namespaceUri string

Returns

string

LookupNamespaceUri(string?)

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

public 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.

public string? LookupPrefix(string? namespaceUri)

Parameters

namespaceUri string

The URI.

Returns

string

The namespace prefix associated with the URI.

NodeIsAdopted(Document)

Run any adopting steps defined for node in other applicable specifications and pass node and oldDocument as parameters.

protected virtual void NodeIsAdopted(Document oldDocument)

Parameters

oldDocument Document

NodeIsInserted(Node)

Specifications may define insertion steps for all or some nodes.

protected virtual void NodeIsInserted(Node newNode)

Parameters

newNode Node

NodeIsRemoved(Node, Node?)

Specifications may define removing steps for all or some nodes.

protected virtual void NodeIsRemoved(Node removedNode, Node? oldPreviousSibling)

Parameters

removedNode Node
oldPreviousSibling Node

Normalize()

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

public void Normalize()

OnParentChanged()

protected virtual void OnParentChanged()

RemoveChild(INode)

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

public INode RemoveChild(INode child)

Parameters

child INode

The child to be removed.

Returns

INode

The removed node.

RemoveNode(int, Node)

public void RemoveNode(int index, Node node)

Parameters

index int
node Node

ReplaceChild(INode, INode)

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

public 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.

ReplacedAll()

Called when ReplaceAll was run.

protected virtual void ReplacedAll()

ToHtml(TextWriter, IMarkupFormatter)

Writes the serialization of the node guided by the formatter.

public void ToHtml(TextWriter writer, IMarkupFormatter formatter)

Parameters

writer TextWriter

The output target of the serialization.

formatter IMarkupFormatter

The formatter to use.