using System.Collections.Generic;
using System.Collections;
using System.Data.DataSetExtensions;
using System.Runtime.Remoting;
using System.Globalization;
using System.Runtime.CompilerServices;
public static void Main()
string input = @"<LayoutControl ID=""rootlyt"" Type=""LayoutControl"">
<LayoutGroup ID=""lgp8"" Header=""PersonalInfo"" IsCollapsed=""False"" IsLocked=""False"" Orientation=""Vertical"" View=""GroupBox"" HorizontalAlignment=""Left"" VerticalAlignment=""Top"" Width=""380"" Height=""295"" Type=""GroupItem"" Properties=""IsCollapsible=False,IsCollapsed=False,IsLocked=False,"">
<Element ID=""layout2"" HorizontalAlignment=""Left"" VerticalAlignment=""Top"" Width=""300"" Height=""25"" Label=""Name"" Background=""#00FFFFFF"" ContentName=""txt2"" Type=""TextEdit"" />
XDocument doc = XDocument.Parse(input);
foreach(var element in doc.Descendants("Element").Select(x=> new {element =x, attributes= x.Attributes()}))
var attributes = element.attributes.ToList();
element.element.RemoveAttributes();
foreach(XAttribute attribute in attributes)
element.element.Add(new XElement(attribute.Name, attribute.Value));