Linq query on XML to Select multiple elements of subnodes

Stonefly

New Member
I want to select all distinct values of child from following xml\[code\]<root> <parent> <child>value 1</child> <child>value 2</child> </parent> <parent> <child>value 1</child> <child>value 4</child> </parent></root>\[/code\]I tried following:\[code\]var vals = (from res in XmlResources.Elements("root").Elements("parent") select res) .SelectMany(r => r.Elements("child")).Distinct().ToList();\[/code\]But can't get the value from it, gives me value wrapped in tag and not DistinctIs it possible to show both ways to get it - query and chaining aka lambda.
 
Back
Top