Given the following XDocument, initialized into variable xDoc:
I'm not sure why this is happening, but removing the xmlns attribute from the body element seems to work:
var report = XDocument.Parse(
@"
");
var body = XElement.Parse(
@"
");
XNamespace ns = report.Root.Name.Namespace;
if (body.GetDefaultNamespace() == ns)
{
body.Attribute("xmlns").Remove();
}
var node = report.Root.Element(ns + "ReportSection");
node.AddFirst(body);