I'm having trouble with a line of code.
I have an XML that has the following data (ID 0, 1, 2, 3, 4 are all the same in this XML. This can be different in another generated XML):
<dissasemblypart>
<ID>0</ID>
<PartType>Tube</PartType>
</dissasemblypart>
<dissasemblypart>
<ID>5</ID>
<PartType>FlatSheetMetal</PartType>
</dissasemblypart>
Now I want to select the Part Type by the ID in the XML but I don't know how to achieve it. I already have the xml reading code, so I will skip that part. All I want to achieve is that the code connects ID and PartType together.
var PartType = partsFromFile.Descendants("PartType");
var PartID = partsFromFile.Descendants("ID");
foreach (var id in PartID)
{
foreach (var type in PartType)
{
WriteLine($"{id.Value}{type.Value}");
}
}
This is the code I currently have, this returns every PartType for every ID, which is close but I know its not what I want returned.
A push in the right way would be highly appreciated.