+ -
当前位置:首页 → 问答吧 → 怎样给XML添加子节点?

怎样给XML添加子节点?

时间:2010-11-18

来源:互联网

XML code
 
<NewDataSet>
<Table>
<product_no>0112630198 </product_no>
<brand>ST&amp;SAT </brand>
<sku>
</sku>
<product_type>1 </product_type>
<price>180.0000 </price>
<price2>128.0000 </price2>
<price3>1.0000 </price3>
<memo>2006年款式 </memo>
<height>
</height>
<height2>
</height2>
<long>
</long>
<specs>咖啡爆裂纹羊皮 </specs>
</Table>
<Table>
<product_no>0112638294 </product_no>
<brand>ST&amp;SAT </brand>
<sku>
</sku>
<product_type>1 </product_type>
<price>190.0000 </price>
<price2>128.0000 </price2>
<price3>1.0000 </price3>
<memo>2006年款式 </memo>
<height>
</height>
<height2>
</height2>
<long>
</long>
<specs>黑色羊绒/黑色布绒 </specs>
</Table>
<NewDataSet>



我现要根据每个product_no值去数据库查询数据并将结果以SKU节点添加起来,如果查询到几个结果就返回几个<sku>
我想要这样的结果

XML code
 
<NewDataSet>
<Table>
<product_no>0112630198 </product_no>
<brand>ST&amp;SAT </brand>
<skus list="true">
<sku>
<created>2010-11-01 10:58:17 </created>
<modified>2010-11-02 19:24:37 </modified>
<outer_id>SSA4SP7281-4 </outer_id>
<price>688.00 </price>
<properties>1627207:28341;21921:28388 </properties>
<quantity>2 </quantity>
<sku_id>7102209263 </sku_id>
</sku>
<sku>
<created>2010-11-01 10:58:17 </created>
<modified>2010-11-02 19:24:37 </modified>
<outer_id>SSA4SP7281-4 </outer_id>
<price>688.00 </price>
<properties>1627207:28341;21921:29542 </properties>
<quantity>3 </quantity>
<sku_id>7102209279 </sku_id>
</sku>
</skus >
<product_type>1 </product_type>
<price>180.0000 </price>
<price2>128.0000 </price2>
<price3>1.0000 </price3>
<memo>2006年款式 </memo>
<height>
</height>
<height2>
</height2>
<long>
</long>
<specs>咖啡爆裂纹羊皮 </specs>
</Table>
<Table>
<product_no>0112638294 </product_no>
<brand>ST&amp;SAT </brand>
<skus list="true">
<sku>
<created>2010-11-01 10:58:17 </created>
<modified>2010-11-02 19:24:37 </modified>
<outer_id>SSA4SP7281-4 </outer_id>
<price>688.00 </price>
<properties>1627207:28341;21921:30106 </properties>
<quantity>2 </quantity>
<sku_id>7102209295 </sku_id>
</sku>
</skus>
<product_type>1 </product_type>
<price>190.0000 </price>
<price2>128.0000 </price2>
<price3>1.0000 </price3>
<memo>2006年款式 </memo>
<height>
</height>
<height2>
</height2>
<long>
</long>
<specs>黑色羊绒/黑色布绒 </specs>
</Table>
<NewDataSet>

请问大家我该怎么做

作者: duanxifeng888   发布时间: 2010-11-18

appendChild方法就可以
http://msdn.microsoft.com/zh-cn/library/system.xml.xmlnode.appendchild.aspx

你想用什么语言做?

作者: net_lover   发布时间: 2010-11-19

我用的是c#语言,能不能请各位高手贴点代码出来,小弟跪求了

作者: duanxifeng888   发布时间: 2010-11-19

各位大哥高手,有没有办法来实现我上面的结果,就是每个节点为下页面,根据product_no值去查询数据,获了到的结果再插入到每个节点中?小弟跪求了

作者: duanxifeng888   发布时间: 2010-11-19