XML节点处理

XmlDocument xmlDoc = new XmlDocument();

                if (!File.Exists(xmlFileName))
                {
                    return string.Empty;
                }
                xmlDoc.Load(xmlFileName);
                XmlNodeList nodes = xmlDoc.SelectNodes(keyPath);

                foreach (XmlNode node in nodes)
                {
                    foreach (XmlNode childNode in node.ChildNodes)
                    {
                        if (childNode.Name == keyName.ToUpper())
                        {
                            string dataValue = childNode.InnerText;
                            return dataValue;
                        }
                    }
                }

 

你可能感兴趣的:(XML节点处理)