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
elementXElementThe element.
attributeXAttributeThe 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
truewhen the element has the name; otherwise,false.
HasElementName(XNode?, XName?)
public static bool HasElementName(this XNode? node, XName? name)
Parameters
Returns
- bool
truewhen the node has the name; otherwise,false.
IsElement(XNode?)
Determines whether the specified node is XElement.
public static bool IsElement(this XNode? node)
Parameters
nodeXNodeThe node.
Returns
- bool
trueif 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
elementXElementThe element.
attributeNamestringName of the attribute.
defaultValuestringThe 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
elementsIEnumerable<XElement>The elements.
Returns
ToElementValueOrNull(XElement?)
Converts the XElement into a element value or null.
public static string? ToElementValueOrNull(this XElement? element)
Parameters
elementXElementThe element.
Returns
WithoutNamespaces(XElement?)
Returns the specified XElement without namespace qualifiers on elements and attributes.
public static XElement? WithoutNamespaces(this XElement? element)
Parameters
elementXElementThe element
Returns
Remarks
Based on “Answer: How to remove all namespaces from XML with C#?” [http://stackoverflow.com/a/7238007/22944?stw=2]