I have created an XDocument from the XML file itself and iterating through the nodes in the document and acting upon them differently using a switch statement. This has worked to how i want it.
int index = 0;
int sIndex = 0;
XDocument xmlDoc = XDocument.Load(file);
List<obj> allObjects = new List<obj>();
List<eventlog> eventLog = new List<eventlog>();
foreach (var obj in xmlDoc.Descendants())
{
switch (obj.Name.LocalName.ToString())
{
case "Obj":
{
Obj newObj = new Obj();
newObj.RefId = obj.Attribute("RefId").Value;
allObjects.Add(newObj);
}
break;
case "MS":
{
MS newMS = new MS();
allObjects[index].MyMS = newMS;
}
break;
case "S":
{
S newS = new S();
newS.Attribute = obj.Attribute("N").Value;
newS.Content = obj.Value.ToString();
allObjects[index].MyMS.S[sIndex] = newS;
sIndex++;
if (sIndex == 3)
sIndex = 0;
}
break;
case "I32":
{
I32 i32 = new I32();
i32.Id = Convert.ToInt32(obj.Value.ToString());
allObjects[index].MyMS.i32 = i32;
index++;
}
break;
default:
break;
}
}</eventlog></eventlog></obj></obj>