Attribute XmlNamespaceDeclarations is ignored during XML serialization

后端 未结 2 1973
粉色の甜心
粉色の甜心 2021-01-18 18:35

I try to serialize an object with custom namespaces. This is how the class looks like:

[XmlRoot(\"Root\", Namespace = \"myNamespace\")]
public partial class          


        
2条回答
  •  清歌不尽
    2021-01-18 18:47

    You wont be able to do anything special to your serialized class - its a known issue. Various workarounds have been suggested here:

    XmlSerializer: remove unnecessary xsi and xsd namespaces

    How to serialize an object to XML without getting xmlns="..."?

    xml serialization - remove namespace

提交回复
热议问题