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(
@"<Report xmlns=""http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"">
<ReportSection>
<Width />
<Page />
</ReportSection>
</Report>");
var body = XElement.Parse(
@"<Body xmlns=""http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"">
<ReportItems />
<Height />
<Style />
</Body>");
XNamespace ns = report.Root.Name.Namespace;
if (body.GetDefaultNamespace() == ns)
{
body.Attribute("xmlns").Remove();
}
var node = report.Root.Element(ns + "ReportSection");
node.AddFirst(body);