regex removing specified empty xml tag using C#
I would like to re开发者_如何学运维move tag like the following one with its attributes using C# .Net how can i do it?
<aaa type="1" class="2" />
other tags like <bbb type="5" class="4" />
i would like to keep.
Best Regards,
I'd advise against regular expressions for this task.
However you can use LINQ to XML to remove tags with name "aaa" like this:
XDocument doc = XDocument.Load("input.xml");
doc.Descendants("aaa").Remove();
doc.Save("output.xml");
精彩评论