AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="1.3.0" />

.NET API 960,512 bytes

 NodeExtensions

public static class NodeExtensions
Useful methods for node objects.
public static void EnsurePreInsertionValidity(this INode parent, INode node, INode child)

Ensures the validity for inserting the given node at parent before the provided child. Throws an error is the insertation is invalid.

public static TNode FindChild<TNode>(this INode parent) where TNode : INode

Tries to find a direct child of a certain type.

public static TNode FindDescendant<TNode>(this INode parent, int maxDepth = 1024) where TNode : INode

Tries to find a descendant of a certain type.

public static T GetAncestor<T>(this INode node) where T : INode

Gets the first ancestor node that is of the specified type.

public static IEnumerable<INode> GetAncestors(this INode node)

Gets the ancestor nodes of the provided node, in tree order.

public static IElement GetAssignedSlot(this IShadowRoot root, string name)

Gets the assigned slot given by the shadow root and the slot name.

public static INode GetAssociatedHost(this INode node)

Gets the associated host object, if any. This is mostly interesting for the HTML5 template tag.

public static IEnumerable<INode> GetDescendants(this INode parent)

Gets the descendant nodes of the provided parent, in tree order.

public static IEnumerable<INode> GetDescendantsAndSelf(this INode parent)

Gets the descendant nodes and itself of the provided parent, in tree order.

public static int GetElementCount(this INode parent)

Gets the element count of the given node.

public static IEnumerable<INode> GetInclusiveAncestors(this INode node)

Gets the inclusive ancestor nodes of the provided node, in tree order.

public static INode GetRoot(this INode node)

Gets the root of the given node, which is the node itself, if it has no parent, or the root of the parent.

public static bool HasDataListAncestor(this INode child)

Checks if any parent is an HTML datalist element..

public static bool HasTextNodes(this INode node)

Checks if the node has any text node children.

public static Url HyperReference(this INode node, string url)

Gets the hyperreference of the given URL - transforming the given (relative) URL to an absolute URL if required.

public static int Index(this INode node)

Gets the index of the provided node in the parent's collection.

public static int Index(this IEnumerable<INode> nodes, INode item)

Gets the index of the given item in the list of nodes.

public static int IndexOf(this INode parent, INode node)

Finds the index of the given node of the provided parent node.

public static bool IsAncestorOf(this INode parent, INode node)

Checks if the parent is an ancestor of the given node.

public static bool IsDescendantOf(this INode node, INode parent)

Checks if the node is an descendant of the given parent.

public static bool IsEndPoint(this INode node)

Checks if the provided node is an endpoint, i.e., does not host any other node.

public static bool IsEndPoint(this NodeType type)

Checks if the provided NodeType is an endpoint, i.e., does not host any other node.

public static bool IsFollowedByDoctype(this INode child)

Checks if the given child is followed by a document type.

public static bool IsFollowing(this INode after, INode before)

Checks if the context node is after the provided node.

public static bool IsHostIncludingInclusiveAncestor(this INode parent, INode node)

Checks for an inclusive ancestor relationship or if the host (if any) has such a relationship.

public static bool IsInclusiveAncestorOf(this INode parent, INode node)

Checks if the parent is an inclusive ancestor of the given node.

public static bool IsInclusiveDescendantOf(this INode node, INode parent)

Checks if the node is an inclusive descendant of the given parent.

public static bool IsInsertable(this INode node)

Checks if the provided node can be inserted into some other node. This excludes, e.g., documents from being inserted.

public static bool IsPrecededByElement(this INode child)

Checks if the given child is preceded by an element node.

public static bool IsPreceding(this INode before, INode after)

Checks if the context node is before the provided node.

public static bool IsSiblingOf(this INode node, INode element)

Checks if the current node is a sibling of the specified element.

public static INode PreInsert(this INode parent, INode node, INode child)

Pre-inserts the given node at the parent before the provided child.

public static INode PreRemove(this INode parent, INode child)

Pre-removes the given child of the parent.

public static string Text(this INode node)

Gets the content text of the given DOM node.

public static T Text<T>(this T nodes, string text) where T : IEnumerable<INode>

Sets the text content of the given elements.