public static void Main() {
var xmlNodes = new XElement( "Nodes",
new XElement( "Node",
new XElement( "Name", "nodeName" ),
new XElement( "Type", "string" )
),
new XElement( "Node",
new XElement( "Name", "True" ),
new XElement( "Type", "bool" )
),
new XElement( "Node",
new XElement( "Name", "42" ),
new XElement( "Type", "int" )
)
);
var converters = new Dictionary<string,Func<string,object> > {
{ "string", val => val },
{ "bool", val => Boolean.Parse( val ) },
{ "int", val => Int32.Parse( val ) }
};
var values =
from node in xmlNodes.Elements( "Node" )
select converters[ node.Element( "Type" ).Value ]( node.Element( "Name" ).Value );
foreach( var value in values )
Console.WriteLine( value.GetType().ToString() + ": " + value );
}