现在我知道这不是新的,而且我已经在网站上做了大量的研究,寻找类似的问题。我有一个像这样的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>
对不起,我知道它漫长而无聊!重要标签是响应标签值。我创建了一个带有相似字段的sql表(名字,姓氏,身份证号码等)。我不知道如何最好地获取数据。我在SSIS中尝试过XML Source,但它似乎没有正确生成XSD,可能是xml结构的cos。我不是很强大,虽然我喜欢ssis ..我猜这个巫师不会工作..我也认为它可能需要改进脚本,因为xml数据可能更多或更少。我使用C#和sql 2012.请问有人能说我如何有效地将xml记录移动到数据库?提前致谢
答案 0 :(得分:0)
您可以使用ssis中的xml任务使用xslt转换来展平xml的结构。 Matt Masson写了一篇关于这个主题的综合博客文章:xml-source-making-things-easier-with-xslt
答案 1 :(得分:0)
如果XML Source不灵活,您是否考虑过在脚本组件中编写自己的解决方案?您可以使用XmlSerializer类对其进行反序列化并将其添加到数据流中。可以在here找到一个如何反序列化它的示例。反序列化XML后,您可以将该数据发送到组件上的output。