I have an xml file.\[code\]<?xml version="1.0" encoding="utf-8" ?><retentions> <client id="1544"> <facility id="5436"> <retention period="23" /> </facility> </client> <client id="7353"> <facility id="3450"> <retention/> </facility> </client></retentions>\[/code\]What I want is to retrieve all attributes, my code:\[code\]var attributes = XDoc.Descendants() .GroupBy(e => e.Name) .ToDictionary(g => g.Key.LocalName, g => g.SelectMany(x => x.Attributes()) .Select(a => (string)a) .ToList()); List<string> x = attributes["retention"];\[/code\]This code doesn't count empty attribute, but I expect it as empty string if no attribute in an element.How to change the code?