XML Annotations
The LINQ to XML API provides the ability to associate a user data object with any class inheriting from the XObject class via annotations. This allows the application developer to assign whatever data type object he wants to an element, document, or any other object whose class is derived from the XObject class. The object could be additional keys for an element's data; it could be an object that will parse the element's contents into itself or whatever you need.
Adding Annotations with XObject.AddAnnotation()
Adding annotations is accomplished using the XObject.AddAnnotation method. Here is the prototype:
void XObject.AddAnnotation(object annotation);
Accessing Annotations with XObject.Annotation() or XObject.Annotations() ...
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.