I am reading xml. From this xml I am storing 4 parameters into array.
How do I combine these arrays into one foreach loop so I can store these data into SQL and work with them?
I managed to create .Zip for two arrays. Is it possible to combine 4 arrays like that? Basically I would like to add id and recDate into numbersAndWords array.
XmlDocument doc = new XmlDocument();
doc.LoadXml(result);
var cislo = new List<string>();
var zprava = new List<string>();
var id = new List<string>();
var recDate = new List<string>();
XmlNodeList number = doc.GetElementsByTagName("SenderNumber");
for (int i = 0; i < number.Count; i++)
{
cislo.Add(number[i].InnerXml);
}
XmlNodeList text = doc.GetElementsByTagName("TextDecoded");
for (int i = 0; i < text.Count; i++)
{
zprava.Add(text[i].InnerXml);
}
XmlNodeList idNum = doc.GetElementsByTagName("ID");
for (int i = 0; i < idNum.Count; i++)
{
id.Add(idNum[i].InnerXml);
}
XmlNodeList recDateTime = doc.GetElementsByTagName("ReceivingDateTime");
for (int i = 0; i < recDateTime.Count; i++)
{
recDate.Add(recDateTime[i].InnerXml);
}
var numbersAndWords = cislo.Zip(zprava, (n, w) => new {Number = n, Word = w});
cs.Open();
foreach (var nw in numbersAndWords)
{
MessageBox.Show(nw.Number);
MessageBox.Show(nw.Word);
}