XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("cmdCfg.xml"); XmlNodeList nodeList = xmlDoc.SelectSingleNode("config").ChildNodes; if (nodeList != null) { foreach (XmlNode cmdNode in nodeList) { XmlElement cmdElement = (XmlElement)cmdNode; string id = cmdElement.GetAttribute("id"); XmlNodeList nls = cmdElement.ChildNodes; string showName = cmdNode.SelectSingleNode("show_name").InnerText; string path = cmdNode.SelectSingleNode("path").InnerText; string paramStr = cmdNode.SelectSingleNode("param_str").InnerText; XmlNode paramDetailNode = cmdNode.SelectSingleNode("param_detail[@name='param1']"); string paramDeatilShowName = paramDetailNode.SelectSingleNode("show_name").InnerText; } }
xml文件: