Table of Contents

Class XElementExtensions

Namespace
Songhay.Extensions
Assembly
SonghayCore.dll

Extensions of XElement.

public static class XElementExtensions
Inheritance
XElementExtensions
Inherited Members

Methods

AddOnce(XElement?, XAttribute?)

Prevents the specified XAttribute from being added more than once.

public static void AddOnce(this XElement? element, XAttribute? attribute)

Parameters

element XElement

The element.

attribute XAttribute

The attribute.

GetElement(XNode?, XName?)

Gets the XElement.

public static XElement? GetElement(this XNode? node, XName? name)

Parameters

node XNode

The node.

name XName

The name.

Returns

XElement

HasElementName(XElement?, XName?)

Determines whether the XElement has the specified XName.

public static bool HasElementName(this XElement? element, XName? name)

Parameters

element XElement

The element.

name XName

The name.

Returns

bool

true when the element has the name; otherwise, false.

HasElementName(XNode?, XName?)

Determines whether the XNode has the specified XName.

public static bool HasElementName(this XNode? node, XName? name)

Parameters

node XNode

The node.

name XName

The name.

Returns

bool

true when the node has the name; otherwise, false.

IsElement(XNode?)

Determines whether the specified node is XElement.

public static bool IsElement(this XNode? node)

Parameters

node XNode

The node.

Returns

bool

true if the specified node is element; otherwise, false.

ToAttributeValueOrDefault(XElement?, string?, string?)

Converts the XElement into a attribute value or default.

public static string? ToAttributeValueOrDefault(this XElement? element, string? attributeName, string? defaultValue)

Parameters

element XElement

The element.

attributeName string

Name of the attribute.

defaultValue string

The default value.

Returns

string

ToAttributeValueOrNull(XElement?, string?)

Returns the attribute value or null.

public static string? ToAttributeValueOrNull(this XElement? element, string? attributeName)

Parameters

element XElement

The element.

attributeName string

Name of the attribute.

Returns

string

ToElementValueOrDefault(XElement?, string?)

Converts the XElement into a element value or default.

public static string? ToElementValueOrDefault(this XElement? element, string? defaultValue)

Parameters

element XElement

The element.

defaultValue string

The default value.

Returns

string

ToElementValueOrNull(IEnumerable<XElement>?)

Returns the element value or null.

public static string? ToElementValueOrNull(this IEnumerable<XElement>? elements)

Parameters

elements IEnumerable<XElement>

The elements.

Returns

string

ToElementValueOrNull(XElement?)

Converts the XElement into a element value or null.

public static string? ToElementValueOrNull(this XElement? element)

Parameters

element XElement

The element.

Returns

string

WithoutNamespaces(XElement?)

Returns the specified XElement without namespace qualifiers on elements and attributes.

public static XElement? WithoutNamespaces(this XElement? element)

Parameters

element XElement

The element

Returns

XElement

Remarks

Based on “Answer: How to remove all namespaces from XML with C#?” [http://stackoverflow.com/a/7238007/22944?stw=2]