In my C# codebase, I have a XMLDocument
of the form:
<A>
<B>
<C mlns='blabla' yz='blablaaa'> Hi </C>
<D mlns='blabla' yz='blablaaa'> How </D>
<E mlns='blabla' yz='blablaaa'> Are </E>
<F mlns='blabla' yz='blablaaa'> You </F>
</B>
<B>
<C mlns='blabla' yz='blablaaa'> I </C>
<D mlns='blabla' yz='blablaaa'> am</D>
<E mlns='blabla' yz='blablaaa'> fine</E>
<F mlns='blabla' yz='blablaaa'> thanks</F>
</B>
</A>
Using Linq-to-XML or otherwise, I want to remove the mlns
and yz
attributes for all the elements contained by element B
.
What is the best way to achieve it?
Using LINQ to XML...
Then:
EDIT: I've just noticed that it should be even easier, in fact, using the
Remove
extension method:So you could even do it without the method pretty simply:
if you have only these two attributes,