Created
June 7, 2012 16:09
-
-
Save jchadwick/2889702 to your computer and use it in GitHub Desktop.
Promote XElement to attribute
This file contains 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
private static void PromoteElementToAttribute(XElement element, string xname) | |
{ | |
var names = element.Descendants(xname).ToArray(); | |
foreach(var name in names) | |
{ | |
if (name != null && name.Parent != null) | |
{ | |
name.Parent.SetAttributeValue(xname, name.Value); | |
name.Remove(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment