I have a xml file as follows.
Filename:myapp.connfig
<configuration>
<appSettings>
<add key="Key1" value="false" />
<add key="Key2" value="5893893"/>
<add key="key3" value="44123"/>
</appSettings>
</configuration>
I want to load this xml file into a datagridview.
I am using Linq to XML but not able to load it.
using Code as below
var q = from c in xmlDoc.Root.Descendants("configuration").Elements("appSettings")
select new
{
myKey = c.Element("add").Attributes("key"),
myValue = c.Element("add").Attribute("Value").Value
};
dataGridView1.DataSource = q.ToList();
In the resultset of the query i am getting message as "Empty = "Enumeration yielded no results"".
What is going wrong in above LINQ statement.
Also after loading XML files, I want to edit these values and save back to XML file. How can i accomplish this task.
Thanks in Advance