I am updating some old code of mine and decided to change everything XML related from XPath to Linq (So learn linq meanwhile). I came across this code, Can someone please tell me how to translate this to a linq statement?
var groups = new List<string>();
XPathNodeIterator it = nav.Select("/Document//Tests/Test[Type='Failure']/Groups/Group/Name");
foreach (XPathNavigator group in it)
{
groups.Add(group.Value);
}
Here’s a rough and ready example of getting the
Groupnames via LINQ:Personally this is the kind of code I always like to write unit tests for, giving certain XML and expecting certain values in return.