public static void Main()
<h:table xmlns:h=""http://www.namespaces.com/namespaceOne"">
<h:table xmlns:h=""http://www.namespaces.com/namespaceTwo"">
<h:name>African Coffee Table</h:name>
var doc = XDocument.Parse(xml);
foreach (var namespaceAttribute in doc.Descendants().SelectMany(x => x.Attributes()).Where(x => x.IsNamespaceDeclaration))
doc.Root.Add(new XAttribute(XNamespace.Xmlns + $"h{count}", namespaceAttribute.Value));
namespaceAttribute.Remove();
Console.WriteLine(doc.ToString());