DataContract/DataMember multiple elements in xml

血红的双手。 提交于 2019-12-11 04:25:23

问题


I have an XML like this:

<data>
    <foo>some value</foo>
    <result>...</result>
    <result>...</result>
    <result>...</result>
    ...
</data>

I would like to deserialize it with DataContract/DataMember.. I know how to handle the array/collection of results elements if they were embedded inside a parent object like:

    <data>
    <foo>some value</foo>
    <collectionOfResults>
            <result>...</result>
            <result>...</result>
            <result>...</result>
            ...
    </collectionOfResults>
    </data>

But I don't know how to do it without the embedding element. Do you?


回答1:


If you need to control the format of the XML, then you don't want to use the DataContractSerializer. Use the XML Serializer instead.



来源:https://stackoverflow.com/questions/4565481/datacontract-datamember-multiple-elements-in-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!