using System.Collections;
using System.Collections.Generic;
using System.Data.DataSetExtensions;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using System.Globalization;
using System.Diagnostics;
public static void Main()
string input =@"<manifest xmlns:imsmd=""http://ltsc.ieee.org/xsd/LOM""><resources><resource><file href=""default.xml""><metadata><imsmd:lom /></metadata></file></resource></resources></manifest>";
var doc = XDocument.Parse(input);
doc.Descendants("resource")
.Add(new XElement("file", new XAttribute("href", "testimg.png"),
new XElement("metadata", new XElement(doc.Root.GetNamespaceOfPrefix("imsmd")+ "lom"))));