XML中的DataContract/DataMember多个元素 [英] DataContract/DataMember multiple elements in xml

查看:109
本文介绍了XML中的DataContract/DataMember多个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的XML:

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

我想用DataContract/DataMember反序列化它. 我知道如何将结果元素的数组/集合嵌入到像这样的父对象中:

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?

推荐答案

如果您需要控制XML的格式,则您不想使用DataContractSerializer.请改用XML序列化程序.

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

这篇关于XML中的DataContract/DataMember多个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆