Partilhar via


LINQ to XML Axes

After you have created an XML tree or loaded an XML document into an XML tree, you can query it to find elements and attributes and retrieve their values.

Before you can write any queries, you must understand the LINQ to XML axes. There are two kinds of axis methods: First, there are the methods that you call on a single XElement object, XDocument object, or XNode object. These methods operate on a single object and return a collection of XElement, XAttribute, or XNode objects. Second, there are extension methods that operate on collections and return collections. The extension methods enumerate the source collection, call the appropriate axis method on each item in the collection, and concatenate the results.  

In This Section

Topic Description

LINQ to XML Axes Overview

Defines axes, and explains how they are used in the context of LINQ to XML queries.

How to: Retrieve a Collection of Elements (LINQ to XML)

Introduces the Elements method. This method retrieves a collection of the child elements of an element.

How to: Retrieve the Value of an Element (LINQ to XML)

Shows how to get the values of elements.

How to: Filter on Element Names (LINQ to XML)

Shows how to filter on element names when using axes.

How to: Chain Axis Method Calls (LINQ to XML)

Shows how to chain calls to axes methods.

How to: Retrieve a Single Child Element (LINQ to XML)

Shows how to retrieve a single child element of an element, given the tag name of the child element.

How to: Retrieve a Collection of Attributes (LINQ to XML)

Introduces the Attributes method. This method retrieves the attributes of an element.

How to: Retrieve a Single Attribute (LINQ to XML)

Shows how to retrieve a single attribute of an element, given the attribute name.

How to: Retrieve the Value of an Attribute (LINQ to XML)

Shows how to get the values of attributes.

How to: Retrieve the Shallow Value of an Element

Shows how to retrieve the shallow value of an element.

Language-Integrated Axes in Visual Basic (LINQ to XML)

Summarizes the Visual Basic integrated axes.

See Also

Concepts

Programming Guide (LINQ to XML)

Other Resources

Extension Methods (C# Programming Guide)