我做了一個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