简体   繁体   中英

C# Deserilize from xml to object (<result xmlns=''> was not expected.)

I try to desalinize from XML to object. When i try to execute this code i get this inner exception get error message was not expected. . Please help me. Thank you for all reply.

    <?xml version="1.0" encoding="UTF-8"?>
<result>
    <status>
         <interfaceId>shop.shipping.segment.get</interfaceId>
         <systemStatus>OK</systemStatus>
         <message>OK</message>
         <requestId>714a4983-555f-42d9-aeea-89dae89f2f55</requestId>
         <requests>
            <id>1</id>
            <kbnId>1</kbnId>
         </requests>
    </status>
    <tns:shopMngApiResponse xmlns:tns="http://rakuten.co.jp/rms/mall/shop/mng/api/model/resource">   
        <resultCode>N000</resultCode>
        <resultMessageList>
            <resultMessage>
                <code>N000</code>
                <message>Succeeded.</message>
            </resultMessage>
        </resultMessageList>
        <result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="tns:soryoKbnResourceModel">
            <soryoKbnList>
                    <soryoKbn>
                        <shopId>202317</shopId>
                        <kbnId>1</kbnId>
                        <id>1</id>
                        <name>test name 1</name>
                    </soryoKbn>
                    <soryoKbn>
                        <shopId>202317</shopId>
                        <kbnId>2</kbnId>
                        <id>7</id>
                        <name>test name 2</name>
                    </soryoKbn>
                </soryoKbnList>
          </result>
     </tns:shopMngApiResponse>
</result>

Source Code: https://app.box.com/s/mmuk2ndkmz4llb71ryw81rpzca9mrmge

When deserializing into the "result"- object set the property as following:

 [XmlElement(ElementName = "result", Form = XmlSchemaForm.Qualified)]
 public YOURRESULTOBJECT result { get; set; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM