tags:

views:

198

answers:

1

Hi,

I would like to remove 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,

+2  A: 

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");
Mark Byers