关于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>
c#

2个回答

用xmldocumnet吧

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问