Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过SSIS/SCRIPT将Xml数据移动到SQL表_Sql_Xml_Ssis - Fatal编程技术网

通过SSIS/SCRIPT将Xml数据移动到SQL表

通过SSIS/SCRIPT将Xml数据移动到SQL表,sql,xml,ssis,Sql,Xml,Ssis,现在我知道这并不是什么新鲜事,而且我已经在网站上做了大量的研究,寻找类似的问题。我有这样的xml数据: <CanvasResult> <TotalPages>1</TotalPages> <CurrentPage>1</CurrentPage> <Submissions> <Submission Id="2257280"> <Form Id="414131"> <Name>NATIONAL

现在我知道这并不是什么新鲜事,而且我已经在网站上做了大量的研究,寻找类似的问题。我有这样的xml数据:

<CanvasResult>
<TotalPages>1</TotalPages>
<CurrentPage>1</CurrentPage>
<Submissions>
<Submission Id="2257280">
<Form Id="414131">
<Name>NATIONAL CENSUS MOBILE PORTAL</Name>
<Status>published</Status>
<Version>1</Version>
</Form>
<Date>2013.05.26 10:38:16</Date>
<DeviceDate>2013.05.26 11:43:48</DeviceDate>
<UserName>talk2sexydainty1@yahoo.com</UserName>
<FirstName>Kalifat</FirstName>
<LastName>Census</LastName>
<ResponseID>2A5B1951-1369565028972</ResponseID>
<Sections>
<Section>
<Name>Census Data Capture Portal</Name>
<Screens>
<Screen>
<Name>Census Data Capture Portal</Name>
<Responses>
<Response>
<Label>FirstName:</Label>
<Value>ajape</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>LastName:</Label>
<Value>quadri</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>ID Number:</Label>
<Value>58rs5</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>Nationality:</Label>
<Value>Nigerian</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>Marital Status:</Label>
<Value>Married</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Date Of Birth:</Label>
<Value>08/26/2000</Value>
<Type>Date</Type>
</Response>
<Response>
<Label>Gender:</Label>
<Value>Male</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Residential Address:</Label>
<Value>No godwon omonua</Value>
<Type>Multi-Line Text</Type>
</Response>
<Response>
<Label>Phone No:</Label>
<Value>08134463976</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>Disability</Label>
<Value>NO</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Photo Capture</Label>
<Value>130268022</Value>
<Type>Image Capture</Type>
</Response>
<Response>
<Label>Education:</Label>
<Value>Degree</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Ex Convict:</Label>
<Value>NO</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Career:</Label>
<Value>eCommerce</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Work Experience:</Label>
<Value>Average</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Current Employer:</Label>
<Value>primeplastichem nig ltd</Value>
<Type>Text Box</Type>
</Response>
</Responses>
</Screen>
</Screens>
</Section>
</Sections>
</Submission>
<Submission Id="2263781">
<Form Id="414131">
<Name>NATIONAL CENSUS MOBILE PORTAL</Name>
<Status>published</Status>
<Version>1</Version>
</Form>
<Date>2013.05.28 12:12:51</Date>
<DeviceDate>2013.05.28 12:05:01</DeviceDate>
<UserName>talk2sexydainty1@yahoo.com</UserName>
<FirstName>Kalifat</FirstName>
<LastName>Census</LastName>
<ResponseID>2A5B1951-1369739101634</ResponseID>
<Sections>
<Section>
<Name>Census Data Capture Portal</Name>
<Screens>
<Screen>
<Name>Census Data Capture Portal</Name>
<Responses>
<Response>
<Label>FirstName:</Label>
<Value>micheal</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>LastName:</Label>
<Value>eniolade</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>ID Number:</Label>
<Value>1256</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>Nationality:</Label>
<Value>Nigerian</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>Marital Status:</Label>
<Value>Single</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Date Of Birth:</Label>
<Value>01/28/1986</Value>
<Type>Date</Type>
</Response>
<Response>
<Label>Gender:</Label>
<Value>Male</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Residential Address:</Label>
<Value>Orisunbare</Value>
<Type>Multi-Line Text</Type>
</Response>
<Response>
<Label>Phone No:</Label>
<Value>08039255000</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>Disability</Label>
<Value>NO</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Photo Capture</Label>
<Value>130574405</Value>
<Type>Image Capture</Type>
</Response>
<Response>
<Label>Education:</Label>
<Value>Degree</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Ex Convict:</Label>
<Value>NO</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Career:</Label>
<Value>Information Technology</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Work Experience:</Label>
<Value>Expert</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Current Employer:</Label>
<Value>micheal</Value>
<Type>Text Box</Type>
</Response>
</Responses>
</Screen>
</Screens>
</Section>
</Sections>
</Submission>
<Submission Id="2288255">
<Form Id="414131">
<Name>NATIONAL CENSUS MOBILE PORTAL</Name>
<Status>published</Status>
<Version>1</Version>
</Form>
<Date>2013.05.31 13:53:51</Date>
<DeviceDate>2013.05.31 13:37:16</DeviceDate>
<UserName>ochonogorf@gmail.com</UserName>
<FirstName>Felix</FirstName>
<LastName>Okechukwu</LastName>
<ResponseID>923297e829f566c6-1370007436433</ResponseID>
<Sections>
<Section>
<Name>Census Data Capture Portal</Name>
<Screens>
<Screen>
<Name>Census Data Capture Portal</Name>
<Responses>
<Response>
<Label>FirstName:</Label>
<Value>Felix</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>LastName:</Label>
<Value>Blaze</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>ID Number:</Label>
<Value>00996325</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>Nationality:</Label>
<Value>Nigerian</Value>
<Type>Text Box</Type>
</Response>
<Response>
<Label>Marital Status:</Label>
<Value>Married</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Date Of Birth:</Label>
<Value>05/31/1984</Value>
<Type>Date</Type>
</Response>
<Response>
<Label>Gender:</Label>
<Value>Male</Value>
<Type>Value List</Type>
</Response>
<Response>
<Label>Residential Address:</Label>
<Value>Lagos</Value>
<Type>Multi-Line Text</Type>
</Response>
</Responses>
</Screen>
</Screens>
</Section>
</Sections>
</Submission>
</Submissions>
</CanvasResult>

1.
1.
全国人口普查移动门户
出版
1.
2013.05.26 10:38:16
2013.05.26 11:43:48
talk2sexydainty1@yahoo.com
卡利法特
统计
2A5B1951-1369565028972
普查数据采集门户
普查数据采集门户
名字:
阿贾佩
文本框
姓氏:
四边形
文本框
身份证号码:
58rs5
文本框
国籍:
尼日利亚人
文本框
婚姻状况:
已婚的
价值清单
出生日期:
08/26/2000
日期
性别:
男性的
价值清单
地址:
不,奥莫尼亚
多行文字
电话号码:
08134463976
文本框
残疾
不
价值清单
照片捕获
130268022
图像捕获
教育:
度
价值清单
前罪犯:
不
价值清单
职业:
电子商务
价值清单
工作经验:
平均的
价值清单
现任雇主:
primeplastichem nig有限公司
文本框
全国人口普查移动门户
出版
1.
2013.05.28 12:12:51
2013.05.28 12:05:01
talk2sexydainty1@yahoo.com
卡利法特
统计
2A5B1951-1369739101634
普查数据采集门户
普查数据采集门户
名字:
迈克尔
文本框
姓氏:
埃尼奥拉德
文本框
身份证号码:
1256
文本框
国籍:
尼日利亚人
文本框
婚姻状况:
仅有一个的
价值清单
出生日期:
01/28/1986
日期
性别:
男性的
价值清单
地址:
奥里桑巴雷
多行文字
电话号码:
08039255000
文本框
残疾
不
价值清单
照片捕获
130574405
图像捕获
教育:
度
价值清单
前罪犯:
不
价值清单
职业:
信息技术
价值清单
工作经验:
专家
价值清单
现任雇主:
迈克尔
文本框
全国人口普查移动门户
出版
1.
2013.05.31 13:53:51
2013.05.31 13:37:16
ochonogorf@gmail.com
费利克斯
奥基楚库
923297e829f566c6-1370007436433
普查数据采集门户
普查数据采集门户
名字:
费利克斯
文本框
姓氏:
火焰
文本框
身份证号码:
00996325
文本框
国籍:
尼日利亚人
文本框
婚姻状况:
已婚的
价值清单
出生日期:
05/31/1984
日期
性别:
男性的
价值清单
地址:
拉各斯
多行文字

对不起,我知道它又长又无聊!重要的标签是响应标签值。我已经创建了一个具有类似字段(名字、姓氏、Id号等)的sql表。我不知道如何最好地获取数据。我在SSIS中尝试了XML源代码,但它似乎没有完全正确地生成XSD,可能是因为XML的结构。虽然我爱ssis,但我还不是很强壮。。我猜这个向导不起作用。。我还认为它可能需要一些脚本,因为xml数据可能更多,也可能更少。我使用C#和sql 2012。请告诉我如何有效地将xml记录移动到数据库?提前感谢

您可以使用ssis中的xml任务,通过xslt转换来扁平化xml的结构。
Matt Masson就此主题写了一篇综合性的博客文章:

如果XML源代码不灵活,您是否考虑过在脚本组件中编写自己的解决方案?您可以使用该类对其进行反序列化,并将其添加到数据流中。可以找到如何对其进行反序列化的示例。反序列化XML后,可以将该数据发送到组件上的