0

我想读取一个 XML 文件并将数据拆分为一个父表和 2 个子表。这是数据将去往的 SQL 模式和 XSD。我在想 SSIS 是我想要使用的,但不知道如何去做。我是否应该遍历孩子,然后使用代码插入行。任何想法都会有所帮助。我愿意使用 SSIS 以外的东西。我使用的是 MS SQL Server 2008。

<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="MonthlyReportForm">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="unbounded">
          <xs:element minOccurs="0" name="ReportingDate" type="xs:string" />
          <xs:element minOccurs="0" name="ReportingYear" type="xs:unsignedShort" />
          <xs:element minOccurs="0" name="ReportingRegion" type="xs:string" />
          <xs:element minOccurs="0" name="TeamMembersName" type="xs:string" />
          <xs:element minOccurs="0" name="chkTraining" type="xs:unsignedByte" />
          <xs:element minOccurs="0" name="chkVernacularMaterials" type="xs:unsignedByte" />
          <xs:element minOccurs="0" name="RDHelpText" type="xs:string" />
          <xs:element minOccurs="0" name="chkOutOfCountryForm" type="xs:unsignedByte" />
          <xs:element minOccurs="0" maxOccurs="unbounded" name="TravelData">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" name="TravelRowLocation" type="xs:string" />
                <xs:element minOccurs="0" name="TravelRowTeam" type="xs:string" />
                <xs:element minOccurs="0" name="TravelRowThisMonth" type="xs:unsignedByte" />
                <xs:element minOccurs="0" name="TravelRowNextMonth" type="xs:string" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element minOccurs="0" name="TrainingReport">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="TrainingData">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element minOccurs="0" name="TrainerName" type="xs:string" />
                      <xs:element minOccurs="0" name="TraineeGender" type="xs:string" />
                      <xs:element minOccurs="0" name="TraineeAge" type="xs:decimal" />
                      <xs:element minOccurs="0" name="TraineeLanguage" type="xs:string" />
                      <xs:element minOccurs="0" name="TraineeEducation" type="xs:string" />
                      <xs:element minOccurs="0" name="TraineeProvince" type="xs:string" />
                      <xs:element minOccurs="0" name="TrainingPrepHrs" type="xs:decimal" />
                      <xs:element minOccurs="0" name="TrainingTrainHrs" type="xs:decimal" />
                      <xs:element minOccurs="0" name="TrainingArea" type="xs:unsignedByte" />
                      <xs:element minOccurs="0" name="TrainingActivity" type="xs:string" />
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

在此处输入图像描述

4

0 回答 0