I have an example. I think my example can help you. I have a class
public class Action_Info
{
public string valueResult { get; set; }
public string valueError { get; set; }
public string valueInfo { get; set; }
public long timeWait { get; set; }
}
And a list:
List<Action_Info> listActions;
I have a xml file: <Script> <Action> <Result>Success</Result> <ErrorReason>None</ErrorReason> <InfoID></InfoID> <TimeWait>10941</TimeWait> </Action> <Action> <Result></Result> <ErrorReason></ErrorReason> <InfoID>NewRcvXbarRsData</InfoID> <TimeWait>17666</TimeWait> </Action> <Action> <Result></Result> <ErrorReason></ErrorReason> <InfoID>NewRcvXbarRsData</InfoID> <TimeWait>17953</TimeWait> </Action> </Script> Then I read from xml file to listActions:
XDocument doc = XDocument.Load(filePathXML);
listActions = doc.Descendants("Action").Select(d =>
new Action_Info
{
valueResult = d.Element("Result").Value,
valueError = d.Element("ErrorReason").Value,
valueInfo = d.Element("InfoID").Value,
timeWait = long.Parse(d.Element("TimeWait").Value)
}).ToList();
You can do what you want with your list.