I have this Following XML File:
And I have written this program using DOM to read and store the data into dictionary. But, while printing I am not getting any output. The console remains Blank.
The code is below:
Dictionary dictionary = new Dictionary();
XmlDocument document = new XmlDocument();
document.Load("Employee.xml");
XmlNodeList node1 = document.GetElementsByTagName("Dept Name");
foreach (var item in node1)
{
XmlNodeList node2 = document.GetElementsByTagName("//Emps/Emp");
foreach (var item1 in node2)
{ dictionary.Add(item.ToString(),Convert.ToInt32(item1.ToString()));
}
}
foreach (var item in dictionary)
{
Console.WriteLine("Key= " + item.Key + "\nValues= " + item.Value );
}
Console.ReadLine();
Munták IstvánPosted Mar 13, 2017, 8:54 AM
Jay KamblePosted Mar 14, 2017, 4:33 AM
Munták IstvánPosted Mar 14, 2017, 3:38 AM
Jay KamblePosted Mar 14, 2017, 12:07 AM