I have this very simple xml file :
<?xml version="1.0" encoding="UTF-8"?>
<ConfigurationFile>
<ConfigurationFilePath>Test1</ConfigurationFilePath>
<ConnectionString>Test2</ConnectionString>
<AnalyzeFilePath>Test3</AnalyzeFilePath>
</ConfigurationFile>
And I want to get informations of each field. But this doesn't display anything..
Here is my C# code behind :
private void ParseXMLFile()
{
Console.WriteLine("Parse");
if (configurationPAthFileTextbox.Text != null)
{
Console.WriteLine("file != null");
try
{
XElement main = XElement.Load(configurationPAthFileTextbox.Text);
var results = main.Descendants("ConfigurationFile")
.Select(e => new { ConfigurationFilePath = e.Descendants("ConfigurationFilePath").FirstOrDefault().Value,
ConnectionString = e.Descendants("ConnectionString").FirstOrDefault().Value });
foreach (var result in results)
Console.WriteLine("{0}, {1}", result.ConfigurationFilePath, result.ConnectionString);
Console.ReadLine();
}
catch (Exception e)
{
Debug.WriteLine(e.ToString());
}
}
}