I have an xml mapping file that looks something like this
Just because I like a challenge, here it is in one query:
XDocument test = XDocument.Parse(" ");
var maps = from model in test.Root.Elements("model")
from attr in model.Attributes("name")
from mapping in model.Elements("mapping")
where attr.Value == "modelY" && mapping.Attribute("colour").Value == "White"
select new
{
configCode = mapping.Attribute("configCode").Value
, stConfigCode = mapping.Attribute("stConfigCode").Value
, dgConfigCode = mapping.Attribute("dgConfigCode").Value
};
foreach (var map in maps)
{
Console.Write("configCode: ");
Console.WriteLine(map.configCode);
Console.Write("stConfigCode: ");
Console.WriteLine(map.stConfigCode);
Console.Write("dgConfigCode: ");
Console.WriteLine(map.dgConfigCode);
}