This is my code:
XElement itemsElement = new XElement("Items", string.Empty);
//some code
parentElement.Add(itemsElement);
After that I got this:
<Items xmlns=""></Items>
Parent element hasn’t any namespace. What can I do, to get an Items element without the empty namespace attribute?
It’s all about how you handle your namespaces. The code below creates child items with different namespaces:
It will produce XML that looks like this:
Look at the difference between
child1,child2andchild3.child2is created using the default namespace, which is probably what you want, whilechild3is what you have now.