public void LoadFrom(XmlNode node) { if (this.name == null) { string name = node.Name; if (name != null) { this.name = name.Trim(); } } Dictionary <string, string> nodeAttrDict = XMLUtil.GetNodeAttrs(node); foreach (string key in nodeAttrDict.Keys) { if (this.attrDict.ContainsKey(key)) { continue; } string value = nodeAttrDict.GetOrAddDefault(key, () => ""); this.attrDict[key] = value; } XmlNode child = node.FirstChild; XMLConfig subConfig = null; while (child != null) { if (child.NodeType == XmlNodeType.Element) { if (IsPropertyNode(child)) { LoadProperty(child); } else { string childNodeName = child.Name; if (childNodeName == null) { continue; } childNodeName = childNodeName.Trim(); string parseClassString = XMLUtil.GetNodeAttrValue(child, "parseClass", ""); if (parseClassString.Length > 0) { subConfig = (XMLConfig)Activator.CreateInstance(Type.GetType(parseClassString)); } else { subConfig = new XMLConfig(); } subConfig.parentConfig = this; subConfig.name = childNodeName; subConfig.LoadFrom(child); // 不断循环下一层 this.configList.Add(subConfig); } } child = child.NextSibling; } string configPath = nodeAttrDict.GetOrAddDefault(Config_Path_Key, () => ""); if (configPath.Length > 0) { LoadFrom(configPath); } }