标签:string 节点 tostring bsp combobox 内容 nts tar height
这种形式可以修改任何一个节点:
XmlDocument doc = new XmlDocument(); doc.Load("Event.xml"); XmlElement events = doc.DocumentElement; XmlNode xn = events; foreach (XmlNode node in xn.ChildNodes) { if (node["事件名"].InnerText == textBox1.Text) { XmlNode xnStartTime = node["开始时间"]; xnStartTime["时"].InnerText = comboBox1.SelectedItem.ToString(); xnStartTime["分"].InnerText = comboBox2.SelectedItem.ToString(); XmlNode xnEndTime = node["终止时间"]; xnEndTime["时"].InnerText = comboBox4.SelectedItem.ToString(); xnEndTime["分"].InnerText = comboBox3.SelectedItem.ToString(); int height = ((Convert.ToInt32(comboBox4.Text) - Convert.ToInt32(comboBox1.Text)) * 6 + (Convert.ToInt32(comboBox3.Text) / 10 - Convert.ToInt32(comboBox2.Text) / 10))*9;
node["高度"].InnerText = Convert.ToString(height); if (radioButton1.Checked == true) { node["重要"].InnerText = "是"; } else { node["重要"].InnerText = "否"; } if (radioButton4.Checked == true) { node["紧迫"].InnerText = "是"; } else { node["紧迫"].InnerText = "否"; } } } doc.Save("Event.xml");
标签:string 节点 tostring bsp combobox 内容 nts tar height
原文地址:http://www.cnblogs.com/zhangchaoran/p/6882751.html