Remove “d1p1” namespace prefix in DataContractSerializer XML output

前端 未结 3 798
长情又很酷
长情又很酷 2021-01-04 04:22

I\'m using DatacontractSerializer to serialize my domainModel into a xml file. I\'m getting output like below.



        
3条回答
  •  花落未央
    2021-01-04 05:14

    It looks like DataContractSerializer doesn't give much control over prefixes. The answer to XML Serialization and namespace prefixes suggests using XmlSerializer if you want to control the namespace prefix.

    Your question wasn't clear as to whether you wanted to entirely remove the namespace prefixes for your domain model. Your sample above has several namespace prefixes: d1p1, d2p1, d4p1. Changing namespace for XML file in XSL Translation provides some guidance on prefix renaming using XSLT.

提交回复
热议问题