反序列化复杂的XML

时间:2015-10-13 07:55:57

标签: c# xml

我从名为Ctera的应用程序中收到以下XML:

<obj class="TeamPortal">
    <att id="activationStatus">
        <val>Enabled</val>
    </att>
    <att id="name">
        <val>dana</val>
    </att>
    <att id="createDate">
        <val>2015-06-04T10:01:13</val>
    </att>
    <att id="alerts">
    </att>
    <att id="autoAssignmentRules">
        <list></list>
    </att>
    <att id="totalStorage">
        <obj class="TotalStorage">
            <att id="totalAvailable">
                <val>0</val>
            </att>
            <att id="totalInUse">
                <val>0</val>
            </att>
        </obj>
    </att>
</obj>

我想将其反序列化为如下对象:

public class TeamPortal
{
    public string activationStatus { get; set; }

    public string name { get; set; }

    public string createDate { get; set; }

    public string alerts { get; set; }

    public List<string> autoAssignmentRules { get; set; }

    public TotalStorage totalStorage { get; set; }
}

public class TotalStorage
{
    public int totalAvailable { get; set; }

    public int totalInUse { get; set; }
}

我尽量避免将其解析为键值列表。 我对我收到的XML没有任何控制权。

0 个答案:

没有答案