I have an XML file like this:-

Notice that each <Field></Field> can have different element like the highlighted <I32> or <String>. I want to show the element name in a datagridview like this which Type is for the name of element (either I32 or String or other child element of <Field>) :-

So far, I've tried this code but it return An unhandled exception of type 'System.NullReferenceException'.
XDocument doc = XDocument.Load("GetLotDetails.xml");
var data = doc.Descendants("Document").Where(x => (String)x.Attribute("name") == "DATA").SelectMany(x => x.Elements("Field"));
var query = from d in data
let str = d.Element("String").Name
let other = d.Element("I32").Name
select new
{
Name = d.Attribute("name").Value,
Type = str.Equals("String") ? "String" : (other.Equals("I32") ? "I32" : null),
Value = d.Value,
};
dataGridView1.DataSource = query.ToList();
So the idea is to let the anonymous Type = *whatever element name under field*. How can I extracted different name of element in the LINQ select statement and give it to the same unknown type variable?