XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlPath);
var root = xmlDoc.DocumentElement;//取到根结点
XmlNode newNode = xmlDoc.CreateNode("element", "NewBook", "");
newNode.InnerText = "WPF";
//添加为根元素的第一层子结点
root.AppendChild(newNode);
xmlDoc.Save(xmlPath);