开发者

DataContract/DataMember multiple elements in xml

开发者 https://www.devze.com 2023-02-02 08:29 出处:网络
I have an XML like this: <data> <foo>some value</foo> <result>...</result>

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 DataContr开发者_如何学Goact/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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消