void Main()
{
string path = @"C:\Users\knife\Desktop\test.xml";
XDocument xml = XDocument.Load(path);
XNamespace ns = "http://tempuri.org/TracePersistence.xsd";
var events = xml.Element(ns+"TraceData").Element(ns+"Events").Elements(ns+"Event").Cast<XElement>().ToList();
var result = new List<KeyValuePair<int,string>>();
foreach(var item in events)
{
if(!item.Elements().Any(c=>c.Attribute("name").Value=="CPU"))
continue;
if(!item.Elements().Any(c=>c.Attribute("name").Value=="TextData"))
continue;
result.Add(new KeyValuePair<int,string>(
int.Parse(item.Elements().FirstOrDefault(c=>c.Attribute("name").Value=="CPU").Value),
item.Elements().FirstOrDefault(c=>c.Attribute("name").Value=="TextData").Value
));
}
var query = from item in result
orderby item.Key descending
select new
{
CPU = item.Key,
Statement = item.Value
};
query.Dump();
}