XElementExtensions.GetElement method

Version 1.1.28
.NET Framework 4.8
Namespace Skybrud.Essentials.Xml.Extensions
Assembly Skybrud.Essentials.dll

GetElement(XElement, XName)

Extension method

Gets the first XElement matching the specified name.

public static XElement GetElement(this XElement element, XName name)

Parameters

element XElement

The parent XElement .

name XName

An instance of XName identifying the element.

Returns

An instance of XElement , or null if name doesn't match any elements.

GetElement<T>(XElement, XName, Func<T, TResult>)

Extension method

Gets the first XElement matching the specified name and parses it using callback.

public static T GetElement<T>(this XElement element, XName name, Func<T, TResult> callback)

Type Parameters

T

Parameters

element XElement

The parent XElement .

name XName

An instance of XName identifying the element.

callback Func<T, TResult>

A callback function for parsing the element.

Returns

T

An instance of T, or null if name doesn't match any elements.

GetElement(XElement, string)

Extension method

Gets the first XElement matching the specified expression.

public static XElement GetElement(this XElement element, string expression)

Parameters

element XElement

The parent XElement .

expression String

The XPath expression.

Returns

An instance of XElement , or null if expression doesn't match any elements.

GetElement<T>(XElement, string, Func<T, TResult>)

Extension method

Gets the first XElement matching the specified expression and parses it using callback.

public static T GetElement<T>(this XElement element, string expression, Func<T, TResult> callback)

Type Parameters

T

Parameters

element XElement

The parent XElement .

expression String

The XPath expression.

callback Func<T, TResult>

A callback function for parsing the element.

Returns

T

An instance of T, or null if expression doesn't match any elements.

GetElement(XElement, string, IXmlNamespaceResolver)

Extension method

Gets the first XElement matching the specified expression.

public static XElement GetElement(this XElement element, string expression, IXmlNamespaceResolver resolver)

Parameters

element XElement

The parent XElement .

expression String

The XPath expression.

An instance of IXmlNamespaceResolver for the namespace prefixes in the XPath expression.

Returns

An instance of XElement , or null if expression doesn't match any elements.

GetElement<T>(XElement, string, IXmlNamespaceResolver, Func<T, TResult>)

Extension method

Gets the first XElement matching the specified expression and parses it using callback.

public static T GetElement<T>(this XElement element, string expression, IXmlNamespaceResolver resolver, Func<T, TResult> callback)

Type Parameters

T

Parameters

element XElement

The parent XElement .

expression String

The XPath expression.

An instance of IXmlNamespaceResolver for the namespace prefixes in the XPath expression.

callback Func<T, TResult>

A callback function for parsing the element.

Returns

T

An instance of T, or null if expression doesn't match any elements.

GetElement<T>(XElement, string, IXmlNamespaceResolver, Func<T1, T2, TResult>)

Extension method

Gets an instance of T representing the first element matching the specified XPath expression.

public static T GetElement<T>(this XElement element, string expression, IXmlNamespaceResolver resolver, Func<T1, T2, TResult> callback)

Type Parameters

T

The type of the item to be returned.

Parameters

element XElement

The parent XElement .

expression String

The XPath expression.

An instance of IXmlNamespaceResolver for the namespace prefixes in the XPath expression.

callback Func<T1, T2, TResult>

A callback function for parsing the element.

Returns

T

An instance of T, or null if expression doesn't match any elements.