I have a strange requirement where an application consuming some XML that my application is generating actually needs empty elements to be serialized as parent elements. For exa
You could solve it with a regular expression, making it a two-pass process.
string xml = "element foo=\"bar\" />" string pattern = @"<(?\w+)(?\b.*)/>"; string substitute = @"<${elem} ${body}>${elem}>"; Regex regex = new Regex(pattern); string goodresult = regex.Replace(xml, substitute);