Amit Patel

Amit Patel

  • NA
  • 37
  • 0

LINQ Query of XMl

Jul 16 2019 8:12 AM
<environments>
<environment>
<add key="Test1">
<add key="Test2">
<add key="Test3">
</environments>
</environment>
 
how to read all the list of key using LINQ tried it seems its not working
 
XDocument fooXML = XDocument.Load(configurationFileName);
var query = from a in fooXML.Element("environment").Elements("add")
select new
{
key = a.Attribute("key").Value,
val = a.Attribute("Value").Value
};

Answers (2)