private static string GetEnvironmentConfigValue(XmlDocument configDocument, string environment, string configKey) { DebugGuard.ArgumentIsNotNull(configDocument, "configDocument"); DebugGuard.ArgumentIsNotNullOrEmpty(environment, "environment"); DebugGuard.ArgumentIsNotNullOrEmpty(configKey, "configKey"); var xpath = string.Format("/config/{0}/entry[@key='{1}']", environment, configKey); var xmlNode = configDocument.SelectSingleNode(xpath); if (xmlNode == null) { throw new Exception( string.Format( "Could not find configuration entry {0} for environment {1} in Environment Configuration XML.", configKey, environment)); } return(xmlNode.InnerText); }