日期:2014-05-18  浏览次数:20349 次

sql2005中插入xml数据
update tb_BuySell set bsExtend='
<buysell>
<barnd>产品品牌:DB线'+convert(varchar(20),@i)+'</barnd>
<currentPrice>当前价钱:0.10元</currentPrice>
<orderMin>最小起订:不限</orderMin>
<buyTotalCount>供货总量:不限</buyTotalCount>
<sendDate>发贷总量:不限</sendDate>
<address>所在地:中国广东省深圳市</address>
<availabilityDate>有效期至:2010年09月22日</availabilityDate>
<packDescription>包装说明:???</packDescription>
<logisticsDescription>物流说明:???</logisticsDescription>
</buysell>' where bsID=11

insert into tb_BuySell values('<buysell>
<barnd>DB线'+convert(varchar(20),@i)+'</barnd>
<currentPrice>0.10元</currentPrice>
<orderMin>不限</orderMin>
<buyTotalCount>不限</buyTotalCount>
<sendDate>不限</sendDate>
<address>中国广东省深圳市</address>
<availabilityDate>2010年09月22日</availabilityDate>
<packDescription>???</packDescription>
<logisticsDescription>???</logisticsDescription>
</buysell>')

上面的xml节点已经固定,我想让它更加灵活,自由的变动?
在服务器端怎样通过代码对xml数据进行统一组织(最好有一个操作xml数据的类),然后在往数据库中插入,查询的时候也可以更加方便一些

------解决方案--------------------
SQL code
建议将

[color=#33CCCC]<buysell>
<barnd>产品品牌:DB线'+convert(varchar(20),@i)+'</barnd>
<currentPrice>当前价钱:0.10元</currentPrice>
<orderMin>最小起订:不限</orderMin>
<buyTotalCount>供货总量:不限</buyTotalCount>
<sendDate>发贷总量:不限</sendDate>
<address>所在地:中国广东省深圳市</address>
<availabilityDate>有效期至:2010年09月22日</availabilityDate>
<packDescription>包装说明:???</packDescription>
<logisticsDescription>物流说明:???</logisticsDescription>
</buysell>[/color]
这些xml文件都拆分开存放到DB中,需要的时候再通过xml拼接来实现,你这样都写死了,要是记录很多
你就麻烦了,而且不容易维护。

------解决方案--------------------
SQL code
[Quote=引用:]

引用:

SQL code
建议将

[color=#33CCCC]<buysell>
<barnd>产品品牌:DB线'+convert(varchar(20),@i)+'</barnd>
<currentPrice>当前价钱:0.10元</currentPrice>
<orderMin>最小起订:不限</orderMin>
<buyTotalC……
[/Quote]

程序来操作也比较麻烦,不过应该可以通过程序来操作xml文件,并将数据对应同步到相关表中,这样后续你需要这些xml时,通过拼接生成就可以了,应该比你现在的做法好很多。
现在的做法相当不可取,要不后续就是个深渊。

------解决方案--------------------
[code=SQL][/code]
------解决方案--------------------
http://database.ctocio.com.cn/tips/167/8069667.shtml
------解决方案--------------------
我觉得你这个还是要拆分开放到DB,至于你说的“程序处理”具体指什么呢?
------解决方案--------------------
楼主所说的类,是在哪个开发语言里?