// 确保在 library.xml 中创建一个 utilDb/database 元素 public static XmlElement EnsureUtilDatabaseElement(XmlDocument cfg_dom, string strDbName, string strType) { XmlElement nodeDatabase = cfg_dom.DocumentElement.SelectSingleNode("utilDb/database[@name='" + strDbName + "']") as XmlElement; if (nodeDatabase != null) { nodeDatabase.SetAttribute("type", strType); return(nodeDatabase); } XmlElement container = DomUtil.EnsureContainerElement(cfg_dom, "utilDb"); nodeDatabase = cfg_dom.CreateElement("database"); container.AppendChild(nodeDatabase); nodeDatabase.SetAttribute("name", strDbName); nodeDatabase.SetAttribute("type", strType); return(nodeDatabase); }