【发布时间】:2018-03-28 21:20:32
【问题描述】:
我是 C# 新手,所以这可能是一个简单的答案。我有一个来自 API 的 XElement 列表。我需要将其转换为数据表。我该怎么做?
XElement 列表:
<person><personid>1</personid><name>person1</name></person>
<person><personid>2</personid><name>person2</name></person>
我需要如下数据表格式
PersonID | Name
--------------
1 person1
2 person2
另一件事是我在设计时不知道节点。所以 XElement 可以是格式
<anyrootnode><anynumberofchildnodes/></anyrootnode>
【问题讨论】:
-
你试过什么?你写过代码吗?
-
如果您提前知道架构,请参阅How to get a tablerow out of an xelement?。
标签: c# linq datatable xelement