问题
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