Export (0) Print
Expand All

XElement Class

Represents an XML element.

Namespace:  System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

public class XElement extends XContainer implements IXmlSerializable

This class represents an XML element, the fundamental XML construct.

An element has an XName, optionally one or more attributes, and can optionally contain content (for more information, see Nodes).

An XElement can contain the following types of content:

For details about the valid content of an XElement, see Valid Content of XElement and XDocument Objects.

XElement derives from XContainer, which derives from XNode.

Some XElement methods can be used from XAML. For more information, see LINQ to XML Dynamic Properties.

The following example creates an XML tree. The content of the new element comes from a LINQ query.

No code example is currently available or this language may not be supported.

This example produces the following output:

<Root>
  <Child3>3</Child3>
  <Child4>4</Child4>
  <Child5>5</Child5>
</Root>

The following is the same example, but in this case the XML is in a namespace. For more information, see Working with XML Namespaces.

No code example is currently available or this language may not be supported.

This example produces the following output:

<Root xmlns="http://www.adventure-works.com">
  <Child3>3</Child3>
  <Child4>4</Child4>
  <Child5>5</Child5>
</Root>

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5

.NET Compact Framework

Supported in: 3.5

XNA Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft