Skip to content

Instantly share code, notes, and snippets.

@jchadwick
Created June 7, 2012 16:09
Show Gist options
  • Save jchadwick/2889702 to your computer and use it in GitHub Desktop.
Save jchadwick/2889702 to your computer and use it in GitHub Desktop.
Promote XElement to attribute
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