This code doesn’t work
XmlElement root = LotDocument.DocumentElement;
XmlNode newItem = LotDocument.CreateElement("item");
XmlAttribute newId = LotDocument.CreateAttribute("id");
foreach(XmlElement node in LotDocument.FirstChild){
if(node.Name == "item" && !node.HasAttributes){
node.SetAttributeNode(newId);
}
}
root.AppendChild(newItem);
LotDocument.Save(path);
When I open the xml file afterwards the item node has been added without the ID attribute.
Any help is appreciated