Partilhar via


LINQ to XML Classes Overview

This topic provides a list of the LINQ to XML classes in the System.Xml.Linq namespace, and a short description of each.  

LINQ to XML Classes

XAttribute Class

XAttribute represents an XML attribute. For detailed information and examples, see XAttribute Class Overview.

XCData Class

XCData represents a CDATA text node.

XComment Class

XComment represents an XML comment.

XContainer Class

XContainer is an abstract base class for all nodes that can have child nodes. The following classes derive from the XContainer class:

XDeclaration Class

XDeclaration represents an XML declaration. An XML declaration is used to declare the XML version and the encoding of a document. In addition, an XML declaration specifies whether the XML document is stand-alone. If a document is stand-alone, there are no external markup declarations, either in an external DTD, or in an external parameter entity referenced from the internal subset.

XDocument Class

XDocument represents an XML document. For detailed information and examples, see XDocument Class Overview.

XDocumentType Class

XDocumentType represents an XML Document Type Definition (DTD).

XElement Class

XElement represents an XML element. For detailed information and examples, see XElement Class Overview.

XName Class

XName represents names of elements (XElement) and attributes (XAttribute). For detailed information and examples, see XDocument Class Overview.

LINQ to XML is designed to make XML names as straightforward as possible. Due to their complexity, XML names are often considered to be an advanced topic in XML. Arguably, this complexity comes not from namespaces, which developers use regularly in programming, but from namespace prefixes. Namespace prefixes can be useful to reduce the keystrokes required when you input XML, or to make XML easier to read. However, prefixes are often just a shortcut for using the full XML namespace, and are not required in most cases. LINQ to XML simplifies XML names by resolving all prefixes to their corresponding XML namespace. Prefixes are available, if they are required, through the GetPrefixOfNamespace method.

It is possible, if necessary, to control namespace prefixes. In some circumstances, if you are working with other XML systems, such as XSLT or XAML, you need to control namespace prefixes. For example, if you have an XPath expression that uses namespace prefixes and is embedded in an XSLT stylesheet, you must make sure that your XML document is serialized with namespace prefixes that match those used in the XPath expression.

XNamespace Class

XNamespace represents a namespace for an XElement or XAttribute. Namespaces are a component of an XName.

XNode Class

XNode is an abstract class that represents the nodes of an XML tree. The following classes derive from the XNode class:

XNodeDocumentOrderComparer Class

XNodeDocumentOrderComparer provides functionality to compare nodes for their document order.

XNodeEqualityComparer Class

XNodeEqualityComparer provides functionality to compare nodes for value equality.

XObject Class

XObject is an abstract base class of XNode and XAttribute. It provides annotation and event functionality.

XObjectChange Class

XObjectChange specifies the event type when an event is raised for an XObject.

XObjectChangeEventArgs Class

XObjectChangeEventArgs provides data for the Changing and Changed events.

XProcessingInstruction Class

XProcessingInstruction represents an XML processing instruction. A processing instruction communicates information to an application that processes the XML.

XText Class

XText represents a text node. In most cases, you do not have to use this class. This class is primarily used for mixed content.

See Also

Concepts

LINQ to XML Programming Overview