I have a XDocument that looks like this:
XDocument outputDocument = new XDocument(
new XElement(\"Document\",
new XEleme
Set the Value property of each empty XElement specifically to an empty string.
// Note: This will mutate the specified document.
private static void ForceTags(XDocument document)
{
foreach (XElement childElement in
from x in document.DescendantNodes().OfType()
where x.IsEmpty
select x)
{
childElement.Value = string.Empty;
}
}