Share via


LINQ to XML Annotations

Annotations in LINQ to XML enable you to associate any arbitrary object of any arbitrary type with any XML component in an XML tree.

To add an annotation to an XML component, such as an XElement or XAttribute, you call the AddAnnotation method. You retrieve annotations by type.

Note that annotations are not part of the XML infoset; they are not serialized or deserialized.

Methods

You can use the following methods when working with annotations:

Method

Description

AddAnnotation

Adds an object to the annotation list of an XObject.

Annotation

Gets the first annotation object of the specified type from an XObject.

Annotations

Gets a collection of annotations of the specified type for an XObject.

RemoveAnnotations

Removes the annotations of the specified type from an XObject.

See Also

Concepts

Advanced LINQ to XML Programming