C# Xml Manipulation: Create Node
First loop through your nodes and for each one create a new XmlNode giving the name of the new node and then supplying the inner text to it. Then just add it to the end of the nodes in its parent.
XmlDocument xdocLocalFile = new XmlDocument(); xdocLocalFile.Load("MyXmlFile.xml"); foreach (XmlNode xNodeReplace in xdocLocalFile.SelectNodes("root/phunk")) { XmlNode xNodeNew = xdocLocalFile.CreateNode(XmlNodeType.Element, "NewColumnName", null); xNodeNew.InnerText = "Here is my new value"; xNodeReplace.InsertAfter(xNodeNew, xNodeReplace.LastChild); }
