emailqjc
emailqjc
采纳率0%
2016-03-13 16:52 阅读 1.4k

关于C# 操作XML文件问题

10

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 把分全给哥 2016-03-14 01:18
    点赞 1 评论 复制链接分享
  • EAison EAison 2016-03-13 23:58

    用xmldocumnet吧

    点赞 评论 复制链接分享

相关推荐