XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("path/to/xmlfile.xml");
XmlNode rootNode = xmlDoc.SelectSingleNode("/root"); foreach (XmlNode node in rootNode.ChildNodes) { // do something with each node }
XmlNode newNode = xmlDoc.CreateElement("newNode"); XmlNode rootNode = xmlDoc.SelectSingleNode("/root"); rootNode.AppendChild(newNode);This code creates a new node and adds it as a child node to the root node of an XML document. The XmlDocument class is included in the System.Xml.dll package library.