我做了一个API调用时返回了以下XML。我需要创建一个数组,其中包含<order_status>
,<payment_status>
和<fulfillment_status>
中的每一个的<status>
和<description>
值。任何人都可以分享一些可以帮助我的知识吗?从c#中的xml数据创建一个数组#
<orderwave>
<call_result>
<order>
<order_number>17377</order_number>
<orderwave_order_number>RWD-336475921</orderwave_order_number>
<order_status>
<status>active</status>
<description>This order is free to be charged and shipped. It is open in the orderwave workflow.</description>
</order_status>
<payment_status>
<status>declined</status>
<description>This order has been declined by the payment network.</description>
</payment_status>
<fulfillment_status>
<status>not shipped</status>
<description>This order has not been allocated for shipment.</description>
</fulfillment_status>
</order>
</call_result>
<warning_count>0</warning_count>
<warnings/>
<error_count>0</error_count>
<errors/>
</orderwave>
您应该使用linqToXML可能 –
看一看使用'List','T'是一个对象来保存您想要的数据,然后使用LINQ to XML将文档解析到List中。如果我稍后再来,我会发布一个例子。 –
Tim
这个数组中存储的对象的类型是什么?你想简单地将XML分解为更小的XDocument,还是需要更强大的类型化方法? – Vitaliy