First: This is NOT a duplicate of Reading Child Nodes with XMLReader (Not the same language, Couldn't get it to help me).
I'm pretty new to XMLreading, I am trying to reach the Sub Element of a specific Element but I am having hard time reaching it, here is an example:
The XML element:
<Group ExerciseNumber="0" Name="R33-IOS1_IOS1" ExerciseName="Unallocated" Status="offline" StatusStatistics="0/1">
<Clients>
<Client ClientName="R33-IOS1_IOS1" MachineName="R33-IOS1" ClientType="HC0" ClientStatus="Disconnected" />
</Clients>
<GroupAppendedData GroupID="201" Type="IOS" DomeType="None" ConnectedTo="" ForceType="Enemy" />
</Group>
I am trying to reach the "Client" element from the specific "Group" element, This is my C# code:
while (reader.Read())
{
if (reader.Name.Equals("Group"))
{
name = reader.GetAttribute("Name");
// Now I need to reach the specific "MachineName" attribute of the "Client" sub-element but don't know how.
}
}
reader.Close();
Notes: It's important that the client element reading will be in the same loop iteration (if possible, if not I will have to think of another design for my generating class).
*Editing the XML is not an option.
Thank you.