Mitja Bonca
New Member
In machine.config file there are elements written there by 3rd party software so it looks like this:\[code\]<configuration> <configSections> ... </configSections> ... <Custom> <Level1> ... </Level1> <Level2> ... </Level2> <Level3> <add key="key_text1" value="http://stackoverflow.com/questions/14498130/s1" /> <add key="key_text2" value="http://stackoverflow.com/questions/14498130/s2" /> <add key="key_text3" value="http://stackoverflow.com/questions/14498130/s3" /> </Level3> </Custom></configuration>\[/code\]I want to get e.g. a value ("s2") of "value" attribute where key="key_text2" from configuration/Custom/Level3 node. So far, I tried to open machine.config as an XML and work from there:\[code\]Configuration config = ConfigurationManager.OpenMachineConfiguration();XmlDocument doc = new XmlDocument();doc.LoadXml(config.FilePath);\[/code\]however, I get XmlException "Data at the root level is invalid.". I also don't know how to use Configuration class methods directly to get this done. Any ideas would be appreciated.