C# 使用所有属性的命名更改反序列化
我尝试反序列化xml。 我的序列化程序需要以下格式:C# 使用所有属性的命名更改反序列化,c#,xml,serialization,xml-namespaces,datacontractserializer,C#,Xml,Serialization,Xml Namespaces,Datacontractserializer,我尝试反序列化xml。 我的序列化程序需要以下格式: <GetItemTransactionsResponse xmlns:a="http://schemas.datacontract.org/2004/07/eBay.Service.Core.Soap" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:mAck>Warning</a:mAck> <a:mAc
<GetItemTransactionsResponse xmlns:a="http://schemas.datacontract.org/2004/07/eBay.Service.Core.Soap" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:mAck>Warning</a:mAck>
<a:mAckSpecified>true</a:mAckSpecified>
<a:mAny i:nil="true" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
<a:mBotBlock i:nil="true"/>
<a:mBuild>915</a:mBuild>
<a:mCorrelationID i:nil="true"/>
<a:mDuplicateInvocationDetails i:nil="true"/>
<a:mEIASToken i:nil="true"/>
<GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2008-02-13T03:47:28.106Z</Timestamp>
<Ack>Success</Ack>
<CorrelationID>137541140</CorrelationID>
<Version>553</Version>
<Build>e553_core_Bundled_6057805_R1</Build>
<NotificationEventName>ItemSold</NotificationEventName>
<RecipientUserID>Seller1</RecipientUserID>
<Item>
警告
真的
915
我希望它能采用这种格式:
<GetItemTransactionsResponse xmlns:a="http://schemas.datacontract.org/2004/07/eBay.Service.Core.Soap" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:mAck>Warning</a:mAck>
<a:mAckSpecified>true</a:mAckSpecified>
<a:mAny i:nil="true" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
<a:mBotBlock i:nil="true"/>
<a:mBuild>915</a:mBuild>
<a:mCorrelationID i:nil="true"/>
<a:mDuplicateInvocationDetails i:nil="true"/>
<a:mEIASToken i:nil="true"/>
<GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2008-02-13T03:47:28.106Z</Timestamp>
<Ack>Success</Ack>
<CorrelationID>137541140</CorrelationID>
<Version>553</Version>
<Build>e553_core_Bundled_6057805_R1</Build>
<NotificationEventName>ItemSold</NotificationEventName>
<RecipientUserID>Seller1</RecipientUserID>
<Item>
2008-02-13T03:47:28.106Z
成功
137541140
553
e553_核心_捆绑_6057805_R1
物品出售
卖家1
要告诉它支持第二种格式而不是第一种格式,我需要告诉它:
Dolev您是否有特定的问题,或者您是否要求我们为您编写此文档?从xml转换为xml不是反序列化;你能说明你想做什么吗?这是重构吗?或者…?我尝试反序列化第二种格式,它抱怨它没有mAck属性(就像我在第一种格式中那样)。这意味着我需要删除每个属性开头的m…第一种格式是反序列化所需的格式(somewhy…),我希望它接收第二种格式作为输入。您的类是什么样的?我假设您的XML实际上如下所示: