How to remove namespace from an XML Element using C#

Posted by Nair on Stack Overflow See other posts from Stack Overflow or by Nair
Published on 2010-06-08T17:48:41Z Indexed on 2010/06/08 17:52 UTC
Read the original article Hit count: 944

Filed under:
|

I have an XML where I have a name space '_spreadSheetNameSapce'. In my code I have to add a new element with attribute associated with the name the space and I am doing it like the following

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

It creates the XElement properly but it does insert xmlns="" entry also in the same element. I do not want that element to be created. How can I create the Xelement without the empty name space or how can I remove the namespace after the element is created?

Thanks a lot.

© Stack Overflow or respective owner

Related posts about c#

Related posts about xelement