如何将xml数据导入到sql server 2008表中? [英] How can i import xml data to sql server 2008 table ?

查看:115
本文介绍了如何将xml数据导入到sql server 2008表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个xml文件
命名为

data.xml
该文件中的数据,例如...

i have a xml file
named

data.xml
data in this file like...

<countryData>
   <Country>
      <CName>AMERICAN SAMOA</CName>
      <CCode>AS</CCode>
   </Country>
   <Country>
      <CName>ANDORRA</CName>
      <CCode>AD</CCode>
   </Country>
   <Country>
      <CName>ANGOLA</CName>
      <CCode>AO</CCode>
   </Country>
   <Country>
</countryData>



现在我想在表中插入该数据

表定义类似..

id int
CName varchar(20)
CCode nchar(2)

那我怎样才能将xml数据导入到表中呢?
请帮助...

thnx



now i want to insert that data in table

Table Defination like..

Id int
CName varchar(20)
CCode nchar(2)

then how can i import xml data to Table.....

plese help...

thnx

推荐答案

您可以使用ADO.NET DataSet ReadXml方法.这是MSDN示例. DataSet.ReadXml [ ^ ]
You can use ADO.NET DataSet ReadXml method. Here is MSDN example. DataSet.ReadXml[^]


这可能对您有帮助
http://csharp.net-informations.com /xml/xml-to-database.htm [
This might help you
http://csharp.net-informations.com/xml/xml-to-database.htm[^]


这取决于您要导入它的方式;通过代码或SSIS.

对于SSIS,您可能需要查看以下
http://blogs .msdn.com/b/mattm/archive/2007/12/11/using-xml-source.aspx [
That depends on how you want to import it; via code or SSIS.

For SSIS you may want to look at this http://blogs.msdn.com/b/mattm/archive/2007/12/11/using-xml-source.aspx[^]

For code there is nothing special. Parse the xml and insert.

If you give a little more detail maybe we can give you a more specific answer


这篇关于如何将xml数据导入到sql server 2008表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆