Remove attributes from XElement



Please consider this XElement:



<MySerializeClass xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY">
<F1>1</F1>
<F2>2</F2>
<F3>nima</F3>
</MySerializeClass>


I want to delete xmlns:xsi and xmlns:xsd from above XML. I wrote this code but it does not work:



XAttribute attr = xml.Attribute("xmlns:xsi");
attr.Remove();


I got this error:



Additional information: The ':' character, hexadecimal value 0x3A, cannot be included in a name.



How I can delete above attributes?


No comments:

Post a Comment