I have an XML file as the following:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<plc1>
<ip>192.168.0.170</ip>
<regread>
<article>1000</article>
<prod1>100</prod1>
</regread>
<regwrite>
<registerId>2000</registerId>
<registerDescription>2100</registerDescription>
<registerTarget>3100</registerTarget>
</regwrite>
</plc1>
<plc2>
<ip>192.168.0.171</ip>
<regread>
<article>1000</article>
<prod1>200</prod1>
</regread>
<regwrite>
<registerId>2000</registerId>
<registerDescription>2100</registerDescription>
<registerTarget>3200</registerTarget>
</regwrite>
</plc2>
<plc3>
<ip>192.168.0.172</ip>
<regread>
<article>1000</article>
<prod>300</prod>
</regread>
<regwrite>
<registerId>2000</registerId>
<registerDescription>2100</registerDescription>
<registerTarget>3300</registerTarget>
</regwrite>
</plc3>
</root>
I have to store those nodes' values into a C# struct like this one:
public struct PLC
{
public string ipAddress;
public int article;
public int prod;
public int registerId;
public int registerDescription;
public int registerTarget;
}
I would like to create an array of this struct so that in PLC[0] there will be plc1
node, in PLC[1] there will be plc2
etc..
How can I achieve this? Thanks in advance for your suggestions.