I want to get the name of the node and its corresponding values in a xml file using linq to xml.
I usually do this line of code to get the value of the node and store it in a list
var qry = from c in XElement.Load(commonpath).Elements("Root") select c;
List<string> result = new List<string>();
foreach (var i in qry)
{
result.Add(Convert.ToString(i));
}
But now I want both node name and value to store it in a dictionary
Dictionary<string, double> amount = new Dictionary<string, double>();
var qry = "";//what query here
foreach(var i in qry)
{
amount.Add("Node Name", "Value");
}
So what is the right query for this situation please help. Thanks
I hope this is what you are looking for:
It prints:
Let me know if it is useful.
Good luck!