2 emailqjc emailqjc 于 2016.03.14 00:52 提问

关于C# 操作XML文件问题 10C

1、如何将SQL返回的DataTable生成如下格式?

  <?xml version="1.0" standalone="yes"?>
<SPDHSet>
  <Table TitleId="1">
    <GoodID>0401020014</GoodID>
    <FactCode>3004010200143</FactCode>
    <GoodName>容声家用燃气灶41214</GoodName>
    <Spec>1</Spec>
    <Unit>台</Unit>
    <Retailpric>65</Retailpric>
    <DHQty>1</DHQty>
  </Table>
  <Table TitleId="2">
    <GoodID>1001010283</GoodID>
    <FactCode>6920547800243</FactCode>
    <GoodName>蒂花之秀 八植精华调养洗发乳(焗油·补水)</GoodName>
    <Spec>1*12</Spec>
    <Unit>支</Unit>
    <Retailpric>49.8</Retailpric>
    <DHQty>9999</DHQty>
  </Table>
  <Table TitleId="3">
    <GoodID>0401016766</GoodID>
    <FactCode>6966444435614</FactCode>
    <GoodName>30cm源派诚二层多用蒸锅</GoodName>
    <Spec>1</Spec>
    <Unit>个</Unit>
    <Retailpric>78</Retailpric>
    <DHQty>1</DHQty>
  </Table>
</SPDHSet>
  默认SQL返回的DataTable生成格式如下:
       <?xml version="1.0" standalone="yes"?>
<SPDHSet>
  <Table>
    <GoodID>0401020014</GoodID>
    <FactCode>3004010200143</FactCode>
    <GoodName>容声家用燃气灶41214</GoodName>
    <Spec>1</Spec>
    <Unit>台</Unit>
    <Retailpric>65</Retailpric>
    <DHQty>1</DHQty>
  </Table>
  <Table>
    <GoodID>1001010283</GoodID>
    <FactCode>6920547800243</FactCode>
    <GoodName>蒂花之秀 八植精华调养洗发乳(焗油·补水)</GoodName>
    <Spec>1*12</Spec>
    <Unit>支</Unit>
    <Retailpric>49.8</Retailpric>
    <DHQty>9999</DHQty>
  </Table>
  <Table>
    <GoodID>0401016766</GoodID>
    <FactCode>6966444435614</FactCode>
    <GoodName>30cm源派诚二层多用蒸锅</GoodName>
    <Spec>1</Spec>
    <Unit>个</Unit>
    <Retailpric>78</Retailpric>
    <DHQty>1</DHQty>
  </Table>
</SPDHSet>

2、当XML格式如下,如何根据FactCode条件检索,将满足条件的节点的DHQty的值增加1?
       <?xml version="1.0" standalone="yes"?>
<SPDHSet>
  <Table>
    <GoodID>0401020014</GoodID>
    <FactCode>3004010200143</FactCode>
    <GoodName>容声家用燃气灶41214</GoodName>
    <Spec>1</Spec>
    <Unit>台</Unit>
    <Retailpric>65</Retailpric>
    <DHQty>1</DHQty>
  </Table>
  <Table>
    <GoodID>1001010283</GoodID>
    <FactCode>6920547800243</FactCode>
    <GoodName>蒂花之秀 八植精华调养洗发乳(焗油·补水)</GoodName>
    <Spec>1*12</Spec>
    <Unit>支</Unit>
    <Retailpric>49.8</Retailpric>
    <DHQty>9999</DHQty>
  </Table>
  <Table>
    <GoodID>0401016766</GoodID>
    <FactCode>6966444435614</FactCode>
    <GoodName>30cm源派诚二层多用蒸锅</GoodName>
    <Spec>1</Spec>
    <Unit>个</Unit>
    <Retailpric>78</Retailpric>
    <DHQty>1</DHQty>
  </Table>http://ask.csdn.net/#
</SPDHSet>

2个回答

enpterexpress
enpterexpress   2016.03.14 09:18
EAison
EAison   2016.03.14 07:58

用xmldocumnet吧

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!