This is my code:
XmlElement tagToAdd = xmlDoc.CreateElement("oneTag");
tagToAdd.InnerText = "blah";
addMyNodes.Add(tagToAdd);
xmlDoc1.Root.Element("Properties").Add(addMyNodes);
xmlDoc1.Save(@"C:\Users\John\Desktop\Ugh.xml");
On the line “addMyNodes.Add(tagToAdd);” I want the tagToAdd to be added to addMyNodes which is XElement. But, it doesn’t add it.
xmlDoc1 and xmlDoc are loaded on the same file, but one is XmlDocument and one is XDocument.
You can’t really mix XmlDocument/XmlElement and XDocument/XElement.
Use XDocument/XElement for everything if you can. XmlDocument/XmlElement is more or less deprecated.