Class ParentNodeExtensions
- Namespace
- AngleSharp.Dom
- Assembly
- AngleSharp.dll
Useful methods for parent node objects.
public static class ParentNodeExtensions
- Inheritance
-
ParentNodeExtensions
- Inherited Members
Methods
Ancestors(INode)
Gets the ancestor nodes of the given child.
public static IEnumerable<INode> Ancestors(this INode child)
Parameters
child
INodeThe child of the nodes to gather.
Returns
- IEnumerable<INode>
The ancestor nodes.
Ancestors<TNode>(INode)
Gets the ancestor nodes of the given child.
public static IEnumerable<TNode> Ancestors<TNode>(this INode child)
Parameters
child
INodeThe child of the nodes to gather.
Returns
- IEnumerable<TNode>
The ancestor nodes.
Type Parameters
TNode
The type of nodes to obtain.
AppendElement<TElement>(INode, TElement)
Inserts a node as the last child node of this element.
public static TElement AppendElement<TElement>(this INode parent, TElement element) where TElement : class, IElement
Parameters
parent
INodeThe parent of the node to add.
element
TElementThe element to be appended.
Returns
- TElement
The appended element.
Type Parameters
TElement
The type of element to add.
AppendNodes(INode, params INode[])
Appends nodes to parent node.
public static void AppendNodes(this INode parent, params INode[] nodes)
Parameters
Descendants(INode)
Gets the descendant nodes of the given parent.
public static IEnumerable<INode> Descendants(this INode parent)
Parameters
parent
INodeThe parent of the nodes to gather.
Returns
- IEnumerable<INode>
The descendant nodes.
DescendantsAndSelf(INode)
Gets the descendant nodes including itself of the given parent.
public static IEnumerable<INode> DescendantsAndSelf(this INode parent)
Parameters
parent
INodeThe parent of the nodes to gather.
Returns
- IEnumerable<INode>
The descendant nodes including itself.
DescendantsAndSelf<TNode>(INode)
Gets the descendant nodes including itself of the given parent.
public static IEnumerable<TNode> DescendantsAndSelf<TNode>(this INode parent)
Parameters
parent
INodeThe parent of the nodes to gather.
Returns
- IEnumerable<TNode>
The descendant nodes including itself.
Type Parameters
TNode
The type of nodes to obtain.
Descendants<TNode>(INode)
Gets the descendant nodes of the given parent.
public static IEnumerable<TNode> Descendants<TNode>(this INode parent)
Parameters
parent
INodeThe parent of the nodes to gather.
Returns
- IEnumerable<TNode>
The descendant nodes.
Type Parameters
TNode
The type of nodes to obtain.
Descendents(INode)
Gets the descendant nodes of the given parent.
[Obsolete("Use Descendants")]
public static IEnumerable<INode> Descendents(this INode parent)
Parameters
parent
INodeThe parent of the nodes to gather.
Returns
- IEnumerable<INode>
The descendant nodes.
DescendentsAndSelf(INode)
Gets the descendant nodes including itself of the given parent.
[Obsolete("Use DescendantsAndSelf")]
public static IEnumerable<INode> DescendentsAndSelf(this INode parent)
Parameters
parent
INodeThe parent of the nodes to gather.
Returns
- IEnumerable<INode>
The descendant nodes including itself.
DescendentsAndSelf<TNode>(INode)
Gets the descendant nodes including itself of the given parent.
[Obsolete("Use DescendantsAndSelf")]
public static IEnumerable<TNode> DescendentsAndSelf<TNode>(this INode parent)
Parameters
parent
INodeThe parent of the nodes to gather.
Returns
- IEnumerable<TNode>
The descendant nodes including itself.
Type Parameters
TNode
The type of nodes to obtain.
Descendents<TNode>(INode)
Gets the descendant nodes of the given parent.
[Obsolete("Use Descendants")]
public static IEnumerable<TNode> Descendents<TNode>(this INode parent)
Parameters
parent
INodeThe parent of the nodes to gather.
Returns
- IEnumerable<TNode>
The descendant nodes.
Type Parameters
TNode
The type of nodes to obtain.
InsertAfter(INode, params INode[])
Inserts nodes after the given child.
public static void InsertAfter(this INode child, params INode[] nodes)
Parameters
InsertBefore(INode, params INode[])
Inserts nodes before the given child.
public static void InsertBefore(this INode child, params INode[] nodes)
Parameters
InsertElement<TElement>(INode, TElement, INode)
Inserts the newElement immediately before the referenceElement.
public static TElement InsertElement<TElement>(this INode parent, TElement newElement, INode referenceElement) where TElement : class, IElement
Parameters
parent
INodeThe parent of the node to add.
newElement
TElementThe node to be inserted.
referenceElement
INodeThe existing child element that will succeed the new element.
Returns
- TElement
The inserted element.
Type Parameters
TElement
The type of element to add.
PrependNodes(INode, params INode[])
Prepends nodes to the parent node.
public static void PrependNodes(this INode parent, params INode[] nodes)
Parameters
QuerySelectorAll<TElement>(IParentNode, string)
Returns a list of elements matching the selectors with the provided type.
public static IEnumerable<TElement> QuerySelectorAll<TElement>(this IParentNode parent, string selectors) where TElement : IElement
Parameters
parent
IParentNodeThe parent of the nodes to gather.
selectors
stringThe group of selectors to use.
Returns
- IEnumerable<TElement>
An enumeration with the elements.
Type Parameters
TElement
The type to look for.
QuerySelector<TElement>(IParentNode, string)
Returns the first element matching the selectors with the provided type, or null.
public static TElement? QuerySelector<TElement>(this IParentNode parent, string selectors) where TElement : class, IElement
Parameters
parent
IParentNodeThe parent of the nodes to gather.
selectors
stringThe group of selectors to use.
Returns
- TElement
The element, if there is any.
Type Parameters
TElement
The type to look for.
RemoveElement<TElement>(INode, TElement)
Removes a child node from the current element, which must be a child of the current node.
public static TElement RemoveElement<TElement>(this INode parent, TElement element) where TElement : class, IElement
Parameters
parent
INodeThe parent of the node to remove.
element
TElementThe element to be removed.
Returns
- TElement
The removed element.
Type Parameters
TElement
The type of element.
RemoveFromParent(INode)
Removes the child from its parent.
public static void RemoveFromParent(this INode child)
Parameters
child
INodeThe context object.
ReplaceWith(INode, params INode[])
Replaces the given child with the nodes.
public static void ReplaceWith(this INode child, params INode[] nodes)