I am working on a .Net project recently and was toying with how to bring in configuration data from an XML file. I thought about creating XSD binding objects, but this felt to restrictive. I thought about creating a map for the data, but when you start nesting maps inside of maps ad nauseam, things can get a little confusing. Then I considered using Linq, but this still seems quite tedious. Then I started doing some reading on ExpandoObjects and the dynamic keyword, introduced in C# 4.0.
After some research and trial and error, I came up with The source code is also available this snippet of code that allowed me to create a dynamic object, based on the structure of the given XML document. Enjoy.