I have 2 xelement which I want to merge :
The first one is like this :
<element xmlns="test1">
<child>element child</child>
</element>
The second one is like this :
<element2>
<child2>element2 child2</child2>
</element2>
I would like to obtain the following :
<root xmlns="fusion">
<element xmlns="test1">
<child>element child</child>
</element>
<element2>
<child2>element2 child2</child2>
</element2>
</root>
The problem is that when I try to merge the 2 xelement in my root node, it automatically add an empty xmlns attribute to my second element which I don't want :
<root xmlns="fusion">
<element xmlns="test1">
<child>element child</child>
</element>
<element2 xmlns="">
<child2>element2 child2</child2>
</element2>
</root>
This is my code :
XNamespace defaultNs = "fusion";
var root = new XElement(defaultNs + "root");
root.Add(element);
root.Add(element2); //when I debug and visualize my element2 I don't have this empty xmlns attribute, it's only when I do the fusion that it appears