Remove empty tags from xml doc
Remove empty tags
Remove empty tags from xml document
By using regular expression we can remove empty tags from xml document.
Regex regex = new Regex(@"(\s)*<(\w:\w|\w)*(\s)*/>");
string xml= regex.Replace(xml, string.Empty);
We can also use LINQ to XML as follows
XDocument doc = XDocument.Parse(xml);
doc.Descendants().Where(d => !d.DescendantNodes().OfType
return doc.ToString();
xmls is xml string
Hi Blessy, nice post.
you can also refer to my post at
http://www.dotnetspider.com/resources/37029-How-remove-all-HTML-Tags-from-specified-string.aspx.
This shows how to remove all HTML tags using Regex.