I am looking for a good approach that can remove empty tags from XML efficiently. What do you recommend? Regex? XDocument? XmlTextReader?
For example,
Loading your original into an XDocument and using the following code gives your desired output:
XDocument
var document = XDocument.Parse(original); document.Descendants() .Where(e => e.IsEmpty || String.IsNullOrWhiteSpace(e.Value)) .Remove();