XmlDocument xmlDoc = new XmlDocument(); XmlNode rootNode = xmlDoc.CreateElement("rootNode");
XmlNodeList childNodes = rootNode.ChildNodes; foreach (XmlNode childNode in childNodes) { // Do something with childNode }
XmlAttribute attribute = xmlDoc.CreateAttribute("attributeName"); attribute.Value = "attributeValue"; rootNode.Attributes.Append(attribute);In this example, we are creating an XmlAttribute object and setting its value. We then add it to the attributes of the "rootNode" XmlNode object. The package library used for XmlNode is the System.Xml package.