I want to return a separate attribute of the tool and the process.
It looks like you want this:
var results = from e in apcxmlstate.Elements("thread") group e by Tuple.Create(e.Attribute("process").Value, e.Attribute("tool").Value) into g select g.First().Attribute("tool").Value;
Or in the free syntax:
var results = apcxmlstate .Elements("thread") .GroupBy(e => Tuple.Create(e.Attribute("process").Value, e.Attribute("tool").Value)) .Select(g => g.First().Attribute("tool"));
This will return a tool for each individual tool / process > pair specified in your example { "atool", "btool", "atool", "ctool" } . However, if all you need is different from the values โโof the tool , you can simply do this:
var results = apcxmlstate .Select(e => e.Attribute("tool").Value) .Distinct();
Which will give you { "atool", "btool", "ctool" } .
source share