XML到C#字符串数组

时间:2018-08-22 04:49:20

标签: xml

我有这样的xml

Running scheduled command: '/opt/cpanel/ea-php71/root/usr/bin/php' 'artisan' SyncAPIOrders:orders > '/dev/null' 2>&1

我想将标签名和值都放入字符串[]结果中,这样

<?xml version="1.0" encoding="UTF-8"?>
<case>
   <e>
      <Time>05-08-2018 11:46:19</Time>
      <Number null="true"/>
      <code1 null="true"/>
      <code2>27341</code2>
      <code3>27341</code3>
   </e>
   <e>
      <Time>05-07-2018 12:11:19</Time>
      <Number>WC1110</Number>
      <code1>50121</code1>
      <code2>54091</code2>
      <code3>14880</code3>
   </e>
</case>

我尝试了以下代码,但未指定标签名称(动态),它仅获取非null值,而无法获取标签名称。

result[0] = "Time,05-08-2018 11:46:19";
result[1] = "Number,";
result[2] = "code1,";
result[3] = "code2,27341";
result[4] = "code3,27341";

result[5] = "Time,05-07-2018 12:11:19";
result[6] = "Number,WC1110";
result[7] = "code1,50121";
result[8] = "code2,54091";
result[9] = "code3,14880";

谢谢!

1 个答案:

答案 0 :(得分:0)

我使用选择性粘贴-> XML作为类粘贴方法来生成类,并使用生成的方法来获取值