Import a XML file into SQL Server tables
I am trying to import a XML file to SQL Sever tables using SSIS Data Flow task --> XML Source (I have a XML file and a XSD file).
The XML file looks like this:
<mc MajCmd="Atlantic">
<r Region="East">
<i Installation_UIC="M00146" Installation_Name="MCA Point">
<bc BC="111" BC_Title="Air Runways">
<c Restoration_Cost_C3="0.0000" Comment="" />
</bc>
</i>
</r>
</mc>
and the XSD file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="mc">
<xs:complexType>
<xs:sequence>
<xs:element name="r" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="i" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="bc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="c" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="BC" type="xs:string" />
<xs:attribute name="BC_Title" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Installation_UIC" type="xs:string" />
<xs:attribute name="Installation_Name" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Region" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="MajCmd" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="mc" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
I created 5 tables (mc, r, i, bc and c)form the extraction of the XML file. My problem is the mc table is empty after the extraction.
Could someone please tell me why this is happening? And how to solve this problem, so I can transfer all the data to SQL tables?
Thanks for your help!
Cha
|