I have a XML file with the following structure:
<deftable>
<table>
<job jobname="">
<incond name="" />
<outcond name="" />
</job>
<job jobname="">
<incond name="" />
<outcond name="" />
<incond name="" />
<outcond name="" />
</job>
</table>
<table>
<job jobname="">
<incond name="" />
<outcond name="" />
</job>
<job jobname="">
<incond name="" />
<outcond name="" />
<incond name="" />
<outcond name="" />
</job>
</table>
</deftable>
inside the tag deftable i can have multiple tables. in the table tag i can have multiple JOBs, and inside those I have multiple incond and outcond.
I'm trying to obtain the values for jobname, and also the value for the name attribute of incond and outcond.
I have tried several paths to accomplish this. The latest thing I tried was this, but I can't seem to get it to work.
XmlDocument doc = new XmlDocument();
doc.Load(file);
XmlNodeList nodes = doc.DocumentElement.SelectNodes("/deftable/table");
int i = 1;
foreach (XmlNode node in nodes)
{
Console.WriteLine(node["job"].GetAttribute("jobname") + " -- " + i);
i++;
XmlNodeList nodes2 = doc.DocumentElement.SelectNodes("/deftable/table/job");
foreach (XmlNode item in nodes2)
{
Console.WriteLine(item["incond"].GetAttribute("name"));
}
}
Any help is greatly appreciated.