我有一个 XML 文件。我想创建一个新节点并将其附加到 XML 文件的末尾并将其保存回内存。
<IntCal>
<User>
<Date>12/09/2012</Date>
<Client>abcd</Client>
<Jewellery>Others</Jewellery>
<ROI>7.5</ROI>
<Description>Some Description</Description>
</User>
<IntCal>
我想创建一个新<User>
元素。任何想法如何做到这一点。
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFile);
XmlNode root_node;
//XmlNodeList nodeList = xmlDoc.SelectNodes("/IntCal/User");
XmlDocument new_node = new XmlDocument();
root_node = xmlDoc.CreateElement("IntCal");
xmlDoc.AppendChild(root_node);
谢谢