Class CollectionExtensions
- Namespace
- AngleSharp.Dom
- Assembly
- AngleSharp.dll
A bunch of methods for getting DOM elements on some internal collections.
public static class CollectionExtensions
- Inheritance
-
CollectionExtensions
- Inherited Members
Methods
Accepts(FilterSettings, INode)
Determines if the current filter settings include the provided node.
public static bool Accepts(this FilterSettings filter, INode node)
Parameters
filter
FilterSettingsThe filter settings to use.
node
INodeThe node to check against.
Returns
- bool
True if the node is accepted, otherwise false.
GetElementById(INodeList, string)
Gets an element by its ID.
public static IElement? GetElementById(this INodeList children, string id)
Parameters
Returns
- IElement
The element or null.
GetElementById<T>(IEnumerable<T>, string)
Gets the element with the provided id, if any. Otherwise the element with the same name is searched.
public static T? GetElementById<T>(this IEnumerable<T> elements, string id) where T : class, IElement
Parameters
elements
IEnumerable<T>The list of elements to filter.
id
stringThe id of the element to find.
Returns
- T
The element with the given id, or null.
Type Parameters
T
The type of node to obtain.
GetElementsByName(INodeList, string, List<IElement>)
Gets a list of HTML elements given by their name attribute.
public static void GetElementsByName(this INodeList children, string name, List<IElement> result)
Parameters
children
INodeListThe list to investigate.
name
stringThe name attribute's value.
result
List<IElement>The result collection.
GetNodes<T>(INode, bool, Func<T, bool>?)
Gets the descendants from the provided parent that fulfill the specified predicate, if any.
public static IEnumerable<T> GetNodes<T>(this INode parent, bool deep = true, Func<T, bool>? predicate = null) where T : class, INode
Parameters
parent
INodeThe parent of the descendants.
deep
boolTrue if all descendants, false if only direct descendants should be considered.
predicate
Func<T, bool>The filter function, if any.
Returns
- IEnumerable<T>
The collection with the corresponding elements.
Type Parameters
T
The type of elements to obtain.