This is the same question as: Explicit Element Closing Tags with System.Xml.Linq Namespace
but I use Net 4.0 and the answers do not work anymore.
The problem i
set the value of the XElement to String.Empty
XElement
String.Empty
OR
setting the IsEmpty property to false for all elements not having any child nodes
IsEmpty
false
foreach (XElement childElement in from x in document.DescendantNodes().OfType() where x.IsEmpty select x) { childElement.IsEmpty = false; }