1 static void Main(string[] args) 2 { 3 4 string path = @"D:my.xml"; 5 XElement xml; 6 List<string> lsXmlContent = new List<string>(); 7 try 8 { 9 xml = XElement.Load(path); 10 11 //Get all elements 12 var elements = from p in xml.Descendants() 13 where p.HasElements == false 14 select p.Value; 15 16 //Get all attributes 17 var attributes = from p in xml.Descendants() 18 from q in p.Attributes() 19 select q.Value; 20 21 } 22 catch (Exception ex) { 23 Console.WriteLine(ex.ToString()); 24 } 25 }