下面是我的xml文件的一部分
<teams>
<team-profile>
<name>Australia</name>
<id>1</id>
<stats type="Test">
<span>1877-2010</span>
<matches>721</matches>
<won>339</won>
<lost>186</lost>
<tied>2</tied>
<draw>194</draw>
<percentage>47.01</percentage>
</stats>
<squad>
<player id="135" fullname="Shane Warne"/>
<player id="136" fullname="Damien Martyn"/>
<player id="138" fullname="Michael Clarke"/>
</squad>
</team-profile>
</team>我在某处读到,有一种方法可以将此XML直接保存到数据库中。我正在使用VS2010。我已经为这个xml中需要的数据创建了dataset。有没有办法将这个XML直接映射到dataset上?还有别的主意吗?我还必须将其他一些更复杂的XML文件保存到数据库中。
我已经尝试了xsd.exe为这个XML创建xsd模式。
发布于 2010-06-08 02:07:23
SQL Server 2005+具有原生XML数据类型,如果您创建了一列,则可以简单地对该列执行插入操作,这是一个与您的类似的insert,此表的第二列的数据类型为xml
INSERT INTO docs VALUES (1, '<book genre="security"
publicationdate="2002" ISBN="0-7356-1588-2">
<title>Writing Secure Code</title>
<author>
<first-name>Michael</first-name>
<last-name>Howard</last-name>
</author>
<author>
<first-name>David</first-name>
<last-name>LeBlanc</last-name>
</author>
<price>39.99</price>
</book>')
INSERT INTO docs VALUES (2,
'<doc id="123">
<sections>
<section num="1"><title>XML Schema</title></section>
<section num="3"><title>Benefits</title></section>
<section num="4"><title>Features</title></section>
</sections>
</doc>')https://stackoverflow.com/questions/2991810
复制相似问题