C# winform 創建 xml節點
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Help.basePath);
XmlNode root = xmlDoc.SelectSingleNode("control");
XmlElement timelock = xmlDoc.CreateElement("lock");
XmlElement timelocksub1 = xmlDoc.CreateElement("islock");
timelocksub1.InnerText = checkEditScreenshots.Checked.ToString();
timelock.AppendChild(timelocksub1);
XmlElement timelocksub2 = xmlDoc.CreateElement("locktime");
timelocksub2.InnerText = txtLockTime.Text.Trim();
timelock.AppendChild(timelocksub2);
XmlElement timelocksub3 = xmlDoc.CreateElement("locktimes");
timelocksub3.InnerText = txtLockTimes.Text.Trim();
timelock.AppendChild(timelocksub3);
XmlElement timelocksub4 = xmlDoc.CreateElement("LockRemConType");
timelocksub4.InnerText = Help.LockRemConType.ToString();
timelock.AppendChild(timelocksub4);
XmlElement timelocksub5 = xmlDoc.CreateElement("LockRemCon");
timelocksub5.InnerText = richTxtLockCon.Text.Trim();
timelock.AppendChild(timelocksub5);
root.AppendChild(timelock);
xmlDoc.Save(Help.basePath);
Help.basePath------------------------文件存儲路徑
control----------------------根節點
“ ”內都是想要創建的節點的名,自己任意定義
最後一定要保存xmlDoc.Save(Help.basePath);