Table of Contents

Class QueryExtensions

Namespace
AngleSharp.Dom
Assembly
AngleSharp.dll

Extensions for performing QuerySelector operations.

public static class QueryExtensions
Inheritance
QueryExtensions
Inherited Members

Methods

Contains(ITokenList, string[])

Returns true if the underlying string contains all of the tokens, otherwise false.

public static bool Contains(this ITokenList list, string[] tokens)

Parameters

list ITokenList

The list that is considered.

tokens string[]

The tokens to consider.

Returns

bool

True if the string contained all tokens, otherwise false.

Contains<T>(T, string[])

Returns true if the underlying string contains all of the tokens, otherwise false.

public static bool Contains<T>(this T list, string[] tokens) where T : class, ITokenList

Parameters

list T

The list that is considered.

tokens string[]

The tokens to consider.

Returns

bool

True if the string contained all tokens, otherwise false.

Type Parameters

T

GetElementsByClassName(INodeList, string)

Returns a set of elements which have all the given class names.

public static IHtmlCollection<IElement> GetElementsByClassName(this INodeList elements, string classNames)

Parameters

elements INodeList

The elements to take as source.

classNames string

A string representing the list of class names to match; class names are separated by whitespace.

Returns

IHtmlCollection<IElement>

A collection of HTML elements.

GetElementsByClassName<T>(T, string)

Returns a set of elements which have all the given class names.

public static IHtmlCollection<IElement> GetElementsByClassName<T>(this T elements, string classNames) where T : class, INodeList

Parameters

elements T

The elements to take as source.

classNames string

A string representing the list of class names to match; class names are separated by whitespace.

Returns

IHtmlCollection<IElement>

A collection of HTML elements.

Type Parameters

T

GetElementsByTagName(INodeList, string)

Returns a NodeList of elements with the given tag name. The complete document is searched, including the root node.

public static IHtmlCollection<IElement> GetElementsByTagName(this INodeList elements, string tagName)

Parameters

elements INodeList

The elements to take as source.

tagName string

A string representing the name of the elements. The special string "*" represents all elements.

Returns

IHtmlCollection<IElement>

A NodeList of found elements in the order they appear in the tree.

GetElementsByTagName(INodeList, string?, string)

Returns a list of elements with the given tag name belonging to the given namespace. The complete document is searched, including the root node.

public static IHtmlCollection<IElement> GetElementsByTagName(this INodeList elements, string? namespaceUri, string localName)

Parameters

elements INodeList

The elements to take as source.

namespaceUri string

The namespace URI of elements to look for.

localName string

Either the local name of elements to look for or the special value "*", which matches all elements.

Returns

IHtmlCollection<IElement>

A NodeList of found elements in the order they appear in the tree.

GetElementsByTagName<T>(T, string)

Returns a NodeList of elements with the given tag name. The complete document is searched, including the root node.

public static IHtmlCollection<IElement> GetElementsByTagName<T>(this T elements, string tagName) where T : class, INodeList

Parameters

elements T

The elements to take as source.

tagName string

A string representing the name of the elements. The special string "*" represents all elements.

Returns

IHtmlCollection<IElement>

A NodeList of found elements in the order they appear in the tree.

Type Parameters

T

GetElementsByTagName<T>(T, string?, string)

Returns a list of elements with the given tag name belonging to the given namespace. The complete document is searched, including the root node.

public static IHtmlCollection<IElement> GetElementsByTagName<T>(this T elements, string? namespaceUri, string localName) where T : class, INodeList

Parameters

elements T

The elements to take as source.

namespaceUri string

The namespace URI of elements to look for.

localName string

Either the local name of elements to look for or the special value "*", which matches all elements.

Returns

IHtmlCollection<IElement>

A NodeList of found elements in the order they appear in the tree.

Type Parameters

T

QuerySelector(INodeList, ISelector)

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors.

public static IElement? QuerySelector(this INodeList elements, ISelector selector)

Parameters

elements INodeList

The elements to take as source.

selector ISelector

A selector object.

Returns

IElement

An element object.

QuerySelector(INodeList, string, INode?)

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors. Requires either a non-empty nodelist or a valid scope node.

public static IElement? QuerySelector(this INodeList nodes, string selectorText, INode? scopeNode = null)

Parameters

nodes INodeList

The nodes to take as source.

selectorText string

A string containing one or more CSS selectors separated by commas.

scopeNode INode

The optional node to take as scope.

Returns

IElement

An element object.

QuerySelectorAll(INodeList, ISelector)

Returns a list of the elements within the document (using depth-first pre-order traversal of the document's nodes) that matches the selector.

public static IHtmlCollection<IElement> QuerySelectorAll(this INodeList elements, ISelector selector)

Parameters

elements INodeList

The elements to take as source.

selector ISelector

A selector object.

Returns

IHtmlCollection<IElement>

A HTMLCollection with all elements that match the selection.

QuerySelectorAll(INodeList, ISelector, List<IElement>)

Returns a list of the elements within the document (using depth-first pre-order traversal of the document's nodes) that match the specified group of selectors.

public static void QuerySelectorAll(this INodeList elements, ISelector selector, List<IElement> result)

Parameters

elements INodeList

The elements to take as source.

selector ISelector

A selector object.

result List<IElement>

A reference to the list where to store the results.

QuerySelectorAll(INodeList, string, INode?)

Returns a list of the elements within the document (using depth-first pre-order traversal of the document's nodes) that match the specified group of selectors. Requires either a non-empty nodelist or a valid scope node.

public static IHtmlCollection<IElement> QuerySelectorAll(this INodeList nodes, string selectorText, INode? scopeNode = null)

Parameters

nodes INodeList

The nodes to take as source.

selectorText string

A string containing one or more CSS selectors separated by commas.

scopeNode INode

The optional node to take as scope.

Returns

IHtmlCollection<IElement>

A HTMLCollection with all elements that match the selection.

QuerySelectorAll<T>(T, ISelector)

Returns a list of the elements within the document (using depth-first pre-order traversal of the document's nodes) that matches the selector.

public static IHtmlCollection<IElement> QuerySelectorAll<T>(this T elements, ISelector selector) where T : class, INodeList

Parameters

elements T

The elements to take as source.

selector ISelector

A selector object.

Returns

IHtmlCollection<IElement>

A HTMLCollection with all elements that match the selection.

Type Parameters

T

QuerySelectorAll<T>(T, ISelector, List<IElement>)

Returns a list of the elements within the document (using depth-first pre-order traversal of the document's nodes) that match the specified group of selectors.

public static void QuerySelectorAll<T>(this T elements, ISelector selector, List<IElement> result) where T : class, INodeList

Parameters

elements T

The elements to take as source.

selector ISelector

A selector object.

result List<IElement>

A reference to the list where to store the results.

Type Parameters

T

QuerySelectorAll<T>(T, string, INode?)

Returns a list of the elements within the document (using depth-first pre-order traversal of the document's nodes) that match the specified group of selectors. Requires either a non-empty nodelist or a valid scope node.

public static IHtmlCollection<IElement> QuerySelectorAll<T>(this T nodes, string selectorText, INode? scopeNode = null) where T : class, INodeList

Parameters

nodes T

The nodes to take as source.

selectorText string

A string containing one or more CSS selectors separated by commas.

scopeNode INode

The optional node to take as scope.

Returns

IHtmlCollection<IElement>

A HTMLCollection with all elements that match the selection.

Type Parameters

T

QuerySelector<T>(INodeList, ISelector)

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the given selector.

public static T? QuerySelector<T>(this INodeList elements, ISelector selectors) where T : class

Parameters

elements INodeList

The elements to take as source.

selectors ISelector

A selector object.

Returns

T

An element object.

Type Parameters

T

QuerySelector<T>(T, ISelector)

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors.

public static IElement? QuerySelector<T>(this T elements, ISelector selector) where T : INodeList

Parameters

elements T

The elements to take as source.

selector ISelector

A selector object.

Returns

IElement

An element object.

Type Parameters

T

QuerySelector<T>(T, string, INode?)

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors. Requires either a non-empty nodelist or a valid scope node.

public static IElement? QuerySelector<T>(this T nodes, string selectorText, INode? scopeNode = null) where T : class, INodeList

Parameters

nodes T

The nodes to take as source.

selectorText string

A string containing one or more CSS selectors separated by commas.

scopeNode INode

The optional node to take as scope.

Returns

IElement

An element object.

Type Parameters

T

QuerySelector<TNodeList, T>(TNodeList, ISelector)

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the given selector.

public static T? QuerySelector<TNodeList, T>(this TNodeList elements, ISelector selectors) where TNodeList : class, INodeList where T : class

Parameters

elements TNodeList

The elements to take as source.

selectors ISelector

A selector object.

Returns

T

An element object.

Type Parameters

TNodeList
T