开发者

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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜