If you get an error and you want us to be able to fix it then please show us the code causing the error i.e. state the exact line you get the error for and also show the context like declaration and initialization of all variables involved.

Obviously without knowing your list type I could only make up an example but other than adapting the property names as in

XDocument doc = new XDocument(

new XElement("AM",

from item in mat

select new XElement("HM",

new XElement("FullName", item.fullName),

new XElement("ShortName", item.fhortName),

new XElement("Code", item.fode)

)

));

I don't see any needed changes. Of course the List<hma> mat needs to be populated with some items to get the XML populated too.