private string GetProjectNameByConfig() { LocalConfigXml.SetKey("XMLOfProjectNames.xml", "serverIP", "123"); LocalConfigXml.SetKey("XMLOfProjectNames.xml", "tagItem", "12365465"); LocalConfigXml.GetKey("XMLOfProjectNames.xml", "serverIP"); return(""); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(System.Environment.CurrentDirectory + "/XMLOfProjectNames.xml"); //取根结点 // var root = xmlDoc.DocumentElement;//取到根结点 //取指定的单个结点 XmlNode oldChild = xmlDoc.SelectSingleNode("OPCConfig/connectionstrings/connectionstring"); //取指定的结点的集合 XmlNodeList nodes = xmlDoc.SelectNodes("OPCConfig/connectionstrings/tagsSettings"); //取到所有的xml结点 XmlNodeList nodelist = xmlDoc.GetElementsByTagName("*"); return(oldChild.Name); }
public void test() { LocalConfigXml.SetKey("opcCofig.xml", "serverIP", "2456465"); }