using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class MainClass{
public static void Main(){
XElement xmlTree = new XElement("Root",
new XElement("A",
new XElement("GrandChild", "content")
)
);
IEnumerable grandChild = xmlTree.Descendants("GrandChild");
foreach (XElement el in grandChild.Ancestors())
Console.WriteLine(el.Name);
}
}