Hi Guys..

Hoping you can help here.. I'm dabbling with Linq as I'm wanting to pass a Node Value from the XML file into the Connection String.

Currently my Code seems to be working and holding the Value in the System.(Code Below:)(Screenshot attached also)

         XDocument testXML = XDocument.Load("C:\\twDB.xml");
            var DataBases = from DataBase in testXML.Descendants("DataBase")
            select new
              Connection = DataBase.Element("Connection").Value.ToString()

I placed a textbox1 onto my form just to make sure I could pass the value but i'm not able too?

Any help on this would be great.


Have you tried using XPath?
It will allow you to "query" XML.

For example;

XPathNavigator rootNav = testXML.CreateNavigator();
foreach(XPathNavigator databaseNav in rootNav.Select("/DataBase/Connection"))

or if you really want to use LINQ

XPathNavigator rootNav = testXML.CreateNavigator();
var connection = from nodeSelector in rootNav.Select("/DataBase/Connection")
                 select nodeSelector.Value;