日期:2014-05-20  浏览次数:20848 次

求linq语句
我有一个字符串,字符串如下:
C# code

string str = "<Info><state>待命</state><WId>000028532</WId><BillState>装货中</BillState><Driver>陈靖彩</Driver><items><item><Consignor>利源煤灰</Consignor><Consignee>阿海电站</Consignee>" +
                    "<LoadLocation>利源煤灰</LoadLocation><UnloadLocation>水电七局</UnloadLocation><GoodName>煤灰</GoodName><GoodsBreed>II 级灰</GoodsBreed><GoodPack>散装</GoodPack><Send>0.0000</Send>" +
                    "<Recive>0.0000</Recive></item></items><items><item><Consignor>利源煤灰1</Consignor><Consignee>阿海电站1</Consignee><LoadLocation>利源煤灰1</LoadLocation><UnloadLocation>水电七局1</UnloadLocation>" +
                    "<GoodName>煤灰1</GoodName><GoodsBreed>II 级灰1</GoodsBreed><GoodPack>散装1</GoodPack><Send>0.0000</Send><Recive>0.0000</Recive></item></items><items><item><Consignor>利源煤灰2</Consignor>" +
                    "<Consignee>阿海电站2</Consignee><LoadLocation>利源煤灰2</LoadLocation><UnloadLocation>水电七局2</UnloadLocation><GoodName>煤灰2</GoodName><GoodsBreed>II 级灰2</GoodsBreed><GoodPack>散装2</GoodPack>" +
                    "<Send>0.0000</Send><Recive>0.0000</Recive></item></items></Info>";



字符串的XML格式如下:
XML code

<Info>
  <state>待命</state>
  <WId>000028532</WId>
  <BillState>装货中</BillState>
  <Driver>陈靖彩</Driver>
  <items>
    <item>
      <Consignor>利源煤灰</Consignor>
      <Consignee>阿海电站</Consignee>
      <LoadLocation>利源煤灰</LoadLocation>
      <UnloadLocation>水电七局</UnloadLocation>
      <GoodName>煤灰</GoodName>
      <GoodsBreed>II 级灰</GoodsBreed>
      <GoodPack>散装</GoodPack>
      <Send>0.0000</Send>
      <Recive>0.0000</Recive>
    </item>
  </items>
  <items>
    <item>
      <Consignor>利源煤灰1</Consignor>
      <Consignee>阿海电站1</Consignee>
      <LoadLocation>利源煤灰1</LoadLocation>
      <UnloadLocation>水电七局1</UnloadLocation>
      <GoodName>煤灰1</GoodName>
      <GoodsBreed>II 级灰1</GoodsBreed>
      <GoodPack>散装1</GoodPack>
      <Send>0.0000</Send>
      <Recive>0.0000</Recive>
    </item>
  </items>
  <items>
    <item>
      <Consignor>利源煤灰2</Consignor>
      <Consignee>阿海电站2</Consignee>
      <LoadLocation>利源煤灰2</LoadLocation>
      <UnloadLocation>水电七局2</UnloadLocation>
      <GoodName>煤灰2</GoodName>
      <GoodsBreed>II 级灰2</GoodsBreed>
      <GoodPack>散装2</GoodPack>
      <Send>0.0000</Send>
      <Recive>0.0000</Recive>
    </item>
  </items>
</Info>



字符串解析的结果如下
state WId BillState Driver Consignor Consignee LoadLocation UnloadLocation GoodName  
待命 000028532 装货中 陈靖彩 利源煤灰 阿海电站 利源煤灰 水电七局 煤灰
待命 000028532 装货中 陈靖彩 利源煤灰1 阿海电站1 利源煤灰1 水电七局1 煤灰1
待命 000028532 装货中 陈靖彩 利源煤灰2 阿海电站2 利源煤灰2 水电七局2 煤灰2

求linq语句



------解决方案--------------------
来了。。。。