Last active
August 29, 2015 14:06
-
-
Save volodymyrsmirnov/ef9009943923839aed23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static XElement RemoveAllNamespaces(XElement e) | |
{ | |
return new XElement(e.Name.LocalName, ( | |
from n in e.Nodes() | |
select((n is XElement) ? RemoveAllNamespaces(n as XElement) : n)), | |
(e.HasAttributes) ? (from a in e.Attributes() | |
where (e.Attributes().Where(ah => a.Name != a.Name.LocalName && ah.Name == a.Name.LocalName).Count() == 0) | |
select new XAttribute(a.Name.LocalName, a.Value)) : null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment