I\'m adding a new node at the end of a file, but I get a write error:
This document already has a \'DocumentElement\' node.
My c
You should use
XmlNode refElem = doc.DocumentElement.LastChild;
and
doc.DocumentElement.InsertAfter(entryElement, refElem);
EDIT
You may also use
doc.DocumentElement.AppendChild(entryElement);
In this case refElem is not needed.
refElem