Given some of the comments, let me provide an alternative answer. The original question asked why XmlDocument was not dynamic in .NET 4. While it may be possible to add "expando" property capability to the existing xml document classes via IDynamicMetaObjectProvider
, doing so is likely a non-trivial endeavor. Making the original Xml object model from System.Xml fully dynamic would require some extensive modification of the Xml framework, and would require that IDynamicMetaObjectProvider be added to every object that is involved. That includes XmlDocument, XmlElement, XmlAttribute, XmlNode, and all of the other xml content types like comments, text nodes, etc. In addition, a considerable amount of support infrastructure, internal types, etc. that are involved in the lookup and processing of elements and attributes and values would also need to be modified (open up Reflector, and take a look at System.Xml...more than half of the types are internal, and they are all highly interdependent with each other and the available public types.)
It is also important to consider the proper scope of implementing expando properties for Xml in .NET. Would you stop at just the XmlDocument and related types? Or would it be more appropriate to include XPath, Xml Schema, etc.?
To answer the original question, "Why isn’t XmlDocument dynamic in .NET 4?", I think the simple answer is this: Implementing fully 'dynamic' API's, or in the case of Xml here, API's that provide property expansion of arbitrary xml documents, is far from a trivial task. Given Microsoft's work ethic, it makes logical sense that they would not approach such a task lightly, and if they attempt to implement expando properties for the Xml framework, I would hope and expect it to be done with the same level of careful attention and care they give to the rest of .NET.