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
Properties
BaseUri
Gets a string representing the base URL.
public string BaseUri { get; }
Property Value
BaseUrl
Gets the base url.
public Url? BaseUrl { get; set; }
Property Value
Flags
Gets the associated node flags.
public NodeFlags Flags { get; }
Property Value
HasChildNodes
Gets an indicator if the element has any child nodes, or not.
public bool HasChildNodes { get; }
Property Value
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
NodeType
Gets an unsigned short representing the type of the node.
public NodeType NodeType { get; }
Property Value
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
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
TextContent
Gets or sets the textual content of an element and all its descendants.
public virtual string TextContent { get; set; }
Property Value
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
INodeThe 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
DocumentThe new document owner, if any.
deep
boolTrue 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
boolOptionally: 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
CompareDocumentPosition(INode)
Compares the position of two nodes in a document.
public DocumentPositions CompareDocumentPosition(INode otherNode)
Parameters
otherNode
INodeThe 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
INodeThe 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
GetPrefixAndLocalName(string, ref string?, out string?, out string)
For more information, see: https://dom.spec.whatwg.org/#validate-and-extract
protected static void GetPrefixAndLocalName(string qualifiedName, ref string? namespaceUri, out string? prefix, out string localName)
Parameters
InsertBefore(INode, INode?)
Inserts the newElement immediately before the referenceElement.
public INode InsertBefore(INode newElement, INode? referenceElement)
Parameters
newElement
INodeThe node to be inserted.
referenceElement
INodeThe 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
Returns
InsertNode(int, Node)
public void InsertNode(int index, Node node)
Parameters
InsertText(int, string)
public void InsertText(int index, string s)
Parameters
IsDefaultNamespace(string?)
Indicates whether or not a namespace is the default namespace for a document.
public bool IsDefaultNamespace(string? namespaceUri)
Parameters
namespaceUri
stringThe 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
Returns
LocateNamespace(string)
protected virtual string? LocateNamespace(string prefix)
Parameters
prefix
string
Returns
LocatePrefix(string)
protected virtual string? LocatePrefix(string namespaceUri)
Parameters
namespaceUri
string
Returns
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
stringThe 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
stringThe 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
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
INodeThe child to be removed.
Returns
- INode
The removed node.
RemoveNode(int, Node)
public void RemoveNode(int index, Node node)
Parameters
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
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
TextWriterThe output target of the serialization.
formatter
IMarkupFormatterThe formatter to use.