How to remove namespace from XML element using C #

I have XML where I have a namespace _spreadSheetNameSapce. In my code, I have to add a new element with an attribute associated with the space name, and I do it as follows

XElement customHeading = new XElement("Row",
    new XAttribute(_spreadSheetNameSapce + "AutoFitHeight", "0"));

It creates correctly XElement, but also inserts an element xmlns=""into the same element. I do not want this element to be created. How can I create XElementwithout an empty namespace or how to delete a namespace after creating an element?

+3
source share
1 answer

. , , xmlns="". , , :

XElement customHeading = new XElement(_spreadSheetNameSapce + "Row",
        new XAttribute(_spreadSheetNameSapce + "AutoFitHeight", "0"));

, - , , " ", .

+9

Source: https://habr.com/ru/post/1749070/


All Articles