<PackageReference Include="System.Xml.XDocument" Version="4.0.11-beta-23409" />

System.Xml.Linq.XElement

Represents an XML element. See XElement Class Overview and the Remarks section on this page for usage information and examples.To browse the .NET Framework source code for this type, see the Reference Source.
public static IEnumerable<XElement> EmptySequence { get; }

Gets an empty collection of elements.

public XAttribute FirstAttribute { get; }

Gets the first attribute of this element.

public bool HasAttributes { get; }

Gets a value indicating whether this element as at least one attribute.

public bool HasElements { get; }

Gets a value indicating whether this element has at least one child element.

public bool IsEmpty { get; }

Gets a value indicating whether this element contains no content.

public XAttribute LastAttribute { get; }

Gets the last attribute of this element.

public XName Name { get; set; }

Gets or sets the name of this element.

public string Value { get; set; }

Gets or sets the concatenated text contents of this element.

public XElement(XName name)

Initializes a new instance of the XElement class with the specified name.

public XElement(XName name, object content)

Initializes a new instance of the XElement class with the specified name and content.

public XElement(XName name, object[] content)

Initializes a new instance of the XElement class with the specified name and content.

public XElement(XElement other)

Initializes a new instance of the XElement class from another XElement object.

Initializes a new instance of the XElement class from an XStreamingElement object.

public XElement()

public static XElement Load(string uri)

Loads an XElement from a file.

public static XElement Load(string uri, LoadOptions options)

Loads an XElement from a file, optionally preserving white space, setting the base URI, and retaining line information.

public static XElement Load(Stream stream)

Creates a new XElement instance by using the specified stream.

public static XElement Load(Stream stream, LoadOptions options)

Creates a new XElement instance by using the specified stream, optionally preserving white space, setting the base URI, and retaining line information.

public static XElement Load(TextReader textReader)

Loads an XElement from a TextReader.

public static XElement Load(TextReader textReader, LoadOptions options)

Loads an XElement from a TextReader, optionally preserving white space and retaining line information.

public static XElement Load(XmlReader reader)

Loads an XElement from an XmlReader.

public static XElement Load(XmlReader reader, LoadOptions options)

Loads an XElement from an XmlReader, optionally preserving white space, setting the base URI, and retaining line information.

public static string op_Explicit(XElement element)

Cast the value of this XElement to a String.

public static bool op_Explicit(XElement element)

Cast the value of this XElement to a Boolean.

public static bool? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of Boolean.

public static int op_Explicit(XElement element)

Cast the value of this XElement to an Int32.

public static int? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of Int32.

public static uint op_Explicit(XElement element)

Cast the value of this XElement to a UInt32.

public static uint? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of UInt32.

public static long op_Explicit(XElement element)

Cast the value of this XElement to an Int64.

public static long? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of Int64.

public static ulong op_Explicit(XElement element)

Cast the value of this XElement to a UInt64.

public static ulong? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of UInt64.

public static float op_Explicit(XElement element)

Cast the value of this XElement to a Single.

public static float? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of Single.

public static double op_Explicit(XElement element)

Cast the value of this XElement to a Double.

public static double? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of Double.

public static decimal op_Explicit(XElement element)

Cast the value of this XElement to a Decimal.

public static decimal? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of Decimal.

public static DateTime op_Explicit(XElement element)

Cast the value of this XElement to a DateTime.

public static DateTime? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of DateTime.

public static DateTimeOffset op_Explicit(XElement element)

Cast the value of this XAttribute to a DateTimeOffset.

public static DateTimeOffset? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of DateTimeOffset.

public static TimeSpan op_Explicit(XElement element)

Cast the value of this XElement to a TimeSpan.

public static TimeSpan? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of TimeSpan.

public static Guid op_Explicit(XElement element)

Cast the value of this XElement to a Guid.

public static Guid? op_Explicit(XElement element)

Cast the value of this XElement to a Nullable<T> of Guid.

public static XElement Parse(string text)

Load an XElement from a string that contains XML.

public static XElement Parse(string text, LoadOptions options)

Load an XElement from a string that contains XML, optionally preserving white space and retaining line information.

Returns a collection of elements that contain this element, and the ancestors of this element.

Returns a filtered collection of elements that contain this element, and the ancestors of this element. Only elements that have a matching XName are included in the collection.

public XAttribute Attribute(XName name)

Returns the XAttribute of this XElement that has the specified XName.

Returns a collection of attributes of this element.

Returns a filtered collection of attributes of this element. Only elements that have a matching XName are included in the collection.

Returns a collection of nodes that contain this element, and all descendant nodes of this element, in document order.

Returns a collection of elements that contain this element, and all descendant elements of this element, in document order.

Returns a filtered collection of elements that contain this element, and all descendant elements of this element, in document order. Only elements that have a matching XName are included in the collection.

Gets the default XNamespace of this XElement.

public XNamespace GetNamespaceOfPrefix(string prefix)

Gets the namespace associated with a particular prefix for this XElement.

public string GetPrefixOfNamespace(XNamespace ns)

Gets the prefix associated with a namespace for this XElement.

public void RemoveAll()

Removes nodes and attributes from this XElement.

public void RemoveAttributes()

Removes the attributes of this XElement.

public void ReplaceAll(object content)

Replaces the child nodes and the attributes of this element with the specified content.

public void ReplaceAll(object[] content)

Replaces the child nodes and the attributes of this element with the specified content.

public void ReplaceAttributes(object content)

Replaces the attributes of this element with the specified content.

public void ReplaceAttributes(object[] content)

Replaces the attributes of this element with the specified content.

public void Save(Stream stream)

Outputs this XElement to the specified Stream.

public void Save(Stream stream, SaveOptions options)

Outputs this XElement to the specified Stream, optionally specifying formatting behavior.

public void Save(TextWriter textWriter)

Serialize this element to a TextWriter.

public void Save(TextWriter textWriter, SaveOptions options)

Serialize this element to a TextWriter, optionally disabling formatting.

public void Save(XmlWriter writer)

Serialize this element to an XmlWriter.

public void SetAttributeValue(XName name, object value)

Sets the value of an attribute, adds an attribute, or removes an attribute.

public void SetElementValue(XName name, object value)

Sets the value of a child element, adds a child element, or removes a child element.

public void SetValue(object value)

Sets the value of this element.