<tests>
<test id ="1">
<name> peter </name>
<age> 23 </age>
<informations> bla bla </informations>
</test>
<test id ="41">
<name> besd </name>
<age> 54 </age>
<informations> some other text </informations>
</test>
<test id ="57">
<name> john </name>
<age> 61 </age>
<informations> vintage </informations>
</test>
<test id ="67">
<name> claude </name>
<age> 11 </age>
<informations> motivation </informations>
</test>
</tests>
I managed to get all the above informations inside an XDocument xInformations
.
List<string> testIds = new List<string>();
testIds = xInformations.Descendants("test").Select(x => (string)x.Attribute("id")).ToList();
And now, I do want using foreach
, to read and save all the informations for each id:
foreach (string extId in testIds.Distinct())
{
/// how can I take step by step the name, age, informations for all test cases ?
}
How can I achieve this?