Class SelectorExtensions
- Namespace
- AngleSharp.Dom
- Assembly
- AngleSharp.dll
Defines a set of extension methods involving selectors.
public static class SelectorExtensions
- Inheritance
-
SelectorExtensions
- Inherited Members
Methods
Children(IEnumerable<IElement>, ISelector?)
Gets the children of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Children(this IEnumerable<IElement> elements, ISelector? selector = null)
Parameters
elements
IEnumerable<IElement>The elements owning the children.
selector
ISelectorThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the children.
Children(IEnumerable<IElement>, string?)
Gets the children of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Children(this IEnumerable<IElement> elements, string? selectorText = null)
Parameters
elements
IEnumerable<IElement>The elements owning the children.
selectorText
stringThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the children.
Eq<T>(IEnumerable<T>, int)
Reduces the elements to the one at the given index, if any.
public static T? Eq<T>(this IEnumerable<T> elements, int index) where T : notnull, IElement
Parameters
elements
IEnumerable<T>The collection.
index
intThe index of the element.
Returns
- T
The element, or its default value.
Type Parameters
T
The type of element.
Even<T>(IEnumerable<T>)
Reduces the elements to the ones with even index.
public static IEnumerable<T> Even<T>(this IEnumerable<T> elements) where T : IElement
Parameters
elements
IEnumerable<T>The collection.
Returns
- IEnumerable<T>
The remaining elements.
Type Parameters
T
The type of element.
Filter<T>(IEnumerable<T>, string)
Keeps elements that are matched by the provided selector.
public static IEnumerable<T> Filter<T>(this IEnumerable<T> elements, string selectorText) where T : IElement
Parameters
elements
IEnumerable<T>The elements to be filtered.
selectorText
stringThe CSS selector to use.
Returns
- IEnumerable<T>
The filtered list of elements.
Type Parameters
T
Gt<T>(IEnumerable<T>, int)
Reduces the elements to the ones above the given index.
public static IEnumerable<T> Gt<T>(this IEnumerable<T> elements, int index) where T : IElement
Parameters
elements
IEnumerable<T>The collection.
index
intThe minimum exclusive index.
Returns
- IEnumerable<T>
The remaining elements.
Type Parameters
T
The type of element.
Is<T>(IEnumerable<T>, ISelector)
Keeps elements that are matched by the provided selector.
public static IEnumerable<T> Is<T>(this IEnumerable<T> elements, ISelector selector) where T : IElement
Parameters
elements
IEnumerable<T>The elements to be filtered.
selector
ISelectorThe CSS selector to use.
Returns
- IEnumerable<T>
The filtered list of elements.
Type Parameters
T
Lt<T>(IEnumerable<T>, int)
Reduces the elements to the ones below the given index.
public static IEnumerable<T> Lt<T>(this IEnumerable<T> elements, int index) where T : IElement
Parameters
elements
IEnumerable<T>The collection.
index
intThe maximum exclusive index.
Returns
- IEnumerable<T>
The remaining elements.
Type Parameters
T
The type of element.
Next(IEnumerable<IElement>, ISelector?)
Gets the following siblings of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Next(this IEnumerable<IElement> elements, ISelector? selector = null)
Parameters
elements
IEnumerable<IElement>The elements with siblings.
selector
ISelectorThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the next siblings.
Next(IEnumerable<IElement>, string?)
Gets the following siblings of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Next(this IEnumerable<IElement> elements, string? selectorText = null)
Parameters
elements
IEnumerable<IElement>The elements with siblings.
selectorText
stringThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the next siblings.
Not<T>(IEnumerable<T>, ISelector)
Keeps elements that are not matched by the provided selector.
public static IEnumerable<T> Not<T>(this IEnumerable<T> elements, ISelector selector) where T : IElement
Parameters
elements
IEnumerable<T>The elements to be filtered.
selector
ISelectorThe CSS selector to use.
Returns
- IEnumerable<T>
The filtered list of elements.
Type Parameters
T
Not<T>(IEnumerable<T>, string)
Keeps elements that are not matched by the provided selector.
public static IEnumerable<T> Not<T>(this IEnumerable<T> elements, string selectorText) where T : IElement
Parameters
elements
IEnumerable<T>The elements to be filtered.
selectorText
stringThe CSS selector to use.
Returns
- IEnumerable<T>
The filtered list of elements.
Type Parameters
T
Odd<T>(IEnumerable<T>)
Reduces the elements to the ones with odd index.
public static IEnumerable<T> Odd<T>(this IEnumerable<T> elements) where T : IElement
Parameters
elements
IEnumerable<T>The collection.
Returns
- IEnumerable<T>
The remaining elements.
Type Parameters
T
The type of element.
Parent(IEnumerable<IElement>, ISelector?)
Gets the parents of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Parent(this IEnumerable<IElement> elements, ISelector? selector = null)
Parameters
elements
IEnumerable<IElement>The elements with parents.
selector
ISelectorThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the parents.
Parent(IEnumerable<IElement>, string?)
Gets the parents of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Parent(this IEnumerable<IElement> elements, string? selectorText = null)
Parameters
elements
IEnumerable<IElement>The elements with parents.
selectorText
stringThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the parents.
Previous(IEnumerable<IElement>, ISelector?)
Gets the preceding siblings of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Previous(this IEnumerable<IElement> elements, ISelector? selector = null)
Parameters
elements
IEnumerable<IElement>The elements with siblings.
selector
ISelectorThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the previous siblings.
Previous(IEnumerable<IElement>, string?)
Gets the preceding siblings of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Previous(this IEnumerable<IElement> elements, string? selectorText = null)
Parameters
elements
IEnumerable<IElement>The elements with siblings.
selectorText
stringThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the previous siblings.
Siblings(IEnumerable<IElement>, ISelector?)
Gets the siblings of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Siblings(this IEnumerable<IElement> elements, ISelector? selector = null)
Parameters
elements
IEnumerable<IElement>The elements with siblings.
selector
ISelectorThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the siblings.
Siblings(IEnumerable<IElement>, string?)
Gets the siblings of the provided elements. Optionally uses a CSS selector to filter the results.
public static IEnumerable<IElement> Siblings(this IEnumerable<IElement> elements, string? selectorText = null)
Parameters
elements
IEnumerable<IElement>The elements with siblings.
selectorText
stringThe CSS selector to use, if any.
Returns
- IEnumerable<IElement>
A filtered list containing the siblings.