问题如下:
原XML数据:
- <rs:data>
  <z:row id="91" cinvcode="1050114" cinvname="镀锌扁铁" cinvstd="40*4" cinvm_unit="米" iquantity="2" iunitcost="12" iprice="24" cposition="" cinvdefine11="0" cinvdefine12="0" cinvdefine13="0" cinvdefine14="0" autoid="96" cposname="" bcosting="True" bvmiused="False" editprop="A" /> 
  <z:row id="91" cinvcode="1090021" cinvname="膜合压力表" cinvstd="0-250Kpa" cinvm_unit="只" iquantity="2" iunitcost="21" iprice="42" cposition="" cinvdefine11="0" cinvdefine12="0" cinvdefine13="0" cinvdefine14="0" autoid="97" cposname="" bcosting="True" bvmiused="False" editprop="A" /> 
  </rs:data>
 
生成结果数据内容
- <body>
+ <entry>
  <id>91</id> 
  <autoid>96</autoid> 
  <barcode /> 
  <inventorycode>1050114</inventorycode> 
  <free1 /> 
  <free2 /> 
  <free3 /> 
  <free4 /> 
  <free5 /> 
  <free6 /> 
  <free7 /> 
  <free8 /> 
  <free9 /> 
  <free10 /> 
  <shouldquantity /> 
  <shouldnumber /> 
  <quantity>2</quantity> 
  <cmassunitname>米</cmassunitname> 
  <assitantunit /> 
  <assitantunitname /> 
  <irate /> 
  <number /> 
  <price>12</price> 
  <cost>24</cost> 
  <plancost /> 
  <planprice /> 
  <serial /> 
  <makedate /> 
  <validdate /> 
  <transitionid /> 
  <subbillcode /> 
  <subpurchaseid /> 
  <position /> 
  <itemclasscode /> 
  <itemclassname /> 
  <itemcode /> 
  <itemname /> 
  <define22 /> 
  <define23 /> 
  <define24 /> 
  <define25 /> 
  <define26 /> 
  <define27 /> 
  <define28 /> 
  <define29 /> 
  <define30 /> 
  <define31 /> 
  <define32 /> 
  <define33 /> 
  <define34 /> 
  <define35 /> 
  <define36 /> 
  <define37 /> 
  <subconsignmentid /> 
  <delegateconsignmentid /> 
  <subproducingid /> 
  <subcheckid /> 
  <cRejectCode /> 
  <iRejectIds /> 
  <cCheckPersonCode /> 
  <dCheckDate /> 
  <cCheckCode /> 
  <iMassDate /> 
  <ioritaxcost /> 
  <ioricost /> 
  <iorimoney /> 
  <ioritaxprice /> 
  <iorisum /> 
  <taxrate>0</taxrate> 
  <taxprice /> 
  <isum /> 
  <massunit /> 
  <vmivencode /> 
  </entry>
+ <entry>
  <id>91</id> 
  <autoid>97</autoid> 
  <barcode /> 
  <inventorycode>1090021</inventorycode> 
  <free1 /> 
  <free2 /> 
  <free3 /> 
  <free4 /> 
  <free5 /> 
  <free6 /> 
  <free7 /> 
  <free8 /> 
  <free9 /> 
  <free10 /> 
  <shouldquantity /> 
  <shouldnumber /> 
  <quantity>2</quantity> 
  <cmassunitname>只</cmassunitname> 
  <assitantunit /> 
  <assitantunitname /> 
  <irate /> 
  <number /> 
  <price>21</price> 
  <cost>42</cost> 
  <plancost /> 
  <planprice /> 
  <serial /> 
  <makedate /> 
  <validdate /> 
  <transitionid /> 
  <subbillcode /> 
  <subpurchaseid /> 
  <position /> 
  <itemclasscode /> 
  <itemclassname /> 
  <itemcode /> 
  <itemname /> 
  <define22 /> 
  <define23 /> 
  <define24 /> 
  <define25 /> 
  <define26 /> 
  <define27 /> 
  <define28 /> 
  <define29 /> 
  <define30 /> 
  <define31 /> 
  <define32 /> 
  <define33 /> 
  <define34 /> 
  <define35 /> 
  <define36 /> 
  <define37 /> 
  <subconsignmentid /> 
  <delegateconsignmentid /> 
  <subproducingid /> 
  <subcheckid /> 
  <cRejectCode /> 
  <iRejectIds /> 
  <cCheckPersonCode /> 
  <dCheckDate /> 
  <cCheckCode /> 
  <iMassDate /> 
  <ioritaxcost /> 
  <ioricost /> 
  <iorimoney /> 
  <ioritaxprice /> 
  <iorisum /> 
  <taxrate>0</taxrate> 
  <taxprice /> 
  <isum /> 
  <massunit /> 
  <vmivencode /> 
  </entry>
  </body>我的目的是写一类来解析.不管原数据是多少个节点,生成对应的结果

解决方案 »

  1.   

    你的原XML没给全吧?
    应该是带命名空间的XML
    XML操作请参考
    http://blog.csdn.net/lovefootball/archive/2008/08/21/2785922.aspx 
      

  2.   

    xmldocument吧,与节点个数无关哦。
      

  3.   

    怎么判断 <rs:data> 节点下有多少 <z:row />子节点啊
      

  4.   

    XmlNode node = 你的<rs:data> 节点
    foreach(XmlNode n in node.ChildNodes)
    {
        //这里就是 <z:row />子节点
    }前提是你得拿到<rs:data> 节点
    如何读取XML已经给了你链接了
    自己稍微改下就可以了