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
XElementThe element.
attribute
XAttributeThe attribute.
GetElement(XNode?, XName?)
Gets the XElement.
public static XElement? GetElement(this XNode? node, XName? name)
Parameters
Returns
HasElementName(XElement?, XName?)
public static bool HasElementName(this XElement? element, XName? name)
Parameters
Returns
- bool
true
when the element has the name; otherwise,false
.
HasElementName(XNode?, XName?)
public static bool HasElementName(this XNode? node, XName? name)
Parameters
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
XNodeThe 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
XElementThe element.
attributeName
stringName of the attribute.
defaultValue
stringThe default value.
Returns
ToAttributeValueOrNull(XElement?, string?)
Returns the attribute value or null.
public static string? ToAttributeValueOrNull(this XElement? element, string? attributeName)
Parameters
Returns
ToElementValueOrDefault(XElement?, string?)
Converts the XElement into a element value or default.
public static string? ToElementValueOrDefault(this XElement? element, string? defaultValue)
Parameters
Returns
ToElementValueOrNull(IEnumerable<XElement>?)
Returns the element value or null.
public static string? ToElementValueOrNull(this IEnumerable<XElement>? elements)
Parameters
elements
IEnumerable<XElement>The elements.
Returns
ToElementValueOrNull(XElement?)
Converts the XElement into a element value or null.
public static string? ToElementValueOrNull(this XElement? element)
Parameters
element
XElementThe element.
Returns
WithoutNamespaces(XElement?)
Returns the specified XElement without namespace qualifiers on elements and attributes.
public static XElement? WithoutNamespaces(this XElement? element)
Parameters
element
XElementThe element
Returns
Remarks
Based on “Answer: How to remove all namespaces from XML with C#?” [http://stackoverflow.com/a/7238007/22944?stw=2]