XML Attributes

As I previously mentioned, with the LINQ to XML API, attributes are implemented with the XAttribute class, and unlike the W3C XML DOM API, they do not inherit from a node. Therefore, they have no inheritance relationship with elements. However, in the LINQ to XML API, they are every bit as easy to work with as elements. Let's take a look.

Attribute Creation

Attributes are created just like elements and most other LINQ to XML classes. This topic is covered in the "Creating Attributes with XAttribute" section previously in this chapter.

Attribute Traversal

Attributes can be traversed using the XElement.FirstAttribute, XElement.LastAttribute, XAttribute.NextAttribute, and XAttribute.PreviousAttribute properties and the XElement.Attribute ...

Get Pro LINQ: Language Integrated Query in C# 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.