A4LGSharedFunctions.ConfigUtil.KeyExists C# (CSharp) Method

KeyExists() private static method

private static KeyExists ( XmlDocument xmlDoc, string strKey ) : bool
xmlDoc System.Xml.XmlDocument
strKey string
return bool
        private static bool KeyExists(XmlDocument xmlDoc, string strKey)
        {
            XmlNode appSettingsNode = null;
            try
            {
                appSettingsNode = xmlDoc.SelectSingleNode("configuration/appSettings");

                // Attempt to locate the requested setting.
                foreach (XmlNode childNode in appSettingsNode)
                {
                    if (childNode != null)
                    {
                        if (childNode.NodeType == XmlNodeType.Element)
                        {
                            if (childNode.Attributes.Count > 0)
                            {
                                if (childNode.Attributes["key"] != null)
                                {
                                    if (childNode.Attributes["key"].Value != null)
                                    {
                                        if (childNode.Attributes["key"].Value == strKey)
                                        {
                                            return true;
                                        }
                                    }
                                }
                            }
                        }
                    }

                }
                return false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("KeyExists:  " + ex.Message);
                return false;
            }
            finally
            {
                appSettingsNode = null;
            }
        }