Simple XML file to store info



I want to create a simple XML file to store some settings that can be easily changed in a text editor. This is my XML file:



<connection>
<hostname>the.host.name</hostname>
<port>1000</port>
<database>theDbName</database>
</connection>


I am trying to use Linq to XML now to read that info into my program, but it gives me an error:



Could not find an implementation of the query pattern for source type 'System.Xml.Linq.XElement'. 'Select' not found.



My code is as follows:



XElement root = XElement.Load(".\\Resources\\Connection.xml");
string host = from el in root.Element("hostname") select el.Element("text");

No comments:

Post a Comment