Please consider this XElement:
<MySerializeClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<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?
I would use xml.Attributes().Where(a => a.IsNamespaceDeclaration).Remove()
. Or use xml.Attribute(XNamespace.Xmlns + "xsi").Remove()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With