相关疑难解决方法(0)

在C#中将XML反序列化为对象

所以我有xml看起来像这样:

<todo-list>
  <id type="integer">#{id}</id>
  <name>#{name}</name>
  <description>#{description}</description>
  <project-id type="integer">#{project_id}</project-id>
  <milestone-id type="integer">#{milestone_id}</milestone-id>
  <position type="integer">#{position}</position>

  <!-- if user can see private lists -->
  <private type="boolean">#{private}</private>

  <!-- if the account supports time tracking -->
  <tracked type="boolean">#{tracked}</tracked>

  <!-- if todo-items are included in the response -->
  <todo-items type="array">
    <todo-item>
      ...
    </todo-item>
    <todo-item>
      ...
    </todo-item>
    ...
  </todo-items>
</todo-list>
Run Code Online (Sandbox Code Playgroud)

我将如何使用.NET的序列化库将其反序列化为C#对象?

目前我正在使用反射,我使用命名约定在xml和我的对象之间进行映射.

.net c# serialization

54
推荐指数
3
解决办法
10万
查看次数

标签 统计

.net ×1

c# ×1

serialization ×1