title: Unable to remove empty xmlns attribute from XElement using c#
body: <p>Before posting this question I have tried all other solution on stack, but with no success.</p>
  
  <p>I am unable to remove empty xmlns attribute from XElement using C#, I have tried the following Codes.</p>
  
  <pre><code>XElement.Attributes().Where(a =&gt; a.IsNamespaceDeclaration).Remove();
  </code></pre>
  
  <p>Another one which postted <a href="https://stackoverflow.com/questions/7003983/how-to-remove-xmlns-attribute-from-xmldocument">here</a></p>
  
  <pre><code>foreach (var attr in objXMl.Descendants().Attributes())
  {
      var elem = attr.Parent;
      attr.Remove();
      elem.Add(new XAttribute(attr.Name.LocalName, attr.Value));
  }
  </code></pre>