LINQ to XML annotations (LINQ to XML)

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 aren't part of the XML infoset; they're 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.