SSIS拆分XML文本



我想知道是否有人可以帮助我实现以下目标。我有一个XML文件,其中有一个文本值,每周包含一个值。我想把每个星期都作为一个单独的行放入数据库中。

我知道如何使用SSIS将XML文件放入数据库,但我需要一些关于如何开始拆分文本值的帮助。

非常感谢!

<DATA>
<TIME-SERIES last-update-time="507340800" name="yearly" sample-interval="604800" observations="52" parent="http:client-volume">143 161 175 112 176 191 188 163 268 303 261 270 264 182 318 307 339 310 328 338 407 485 3330 274 168 191 179 258 183 256 258 238 2625 235 305 274 255 273 367 188 318 230 315 278 192 222 1268 129 150 350 3278 4757 </TIME-SERIES>
</DATA>

首选输出

date      | name   | interval | observation | parent             | value
507340800 | yearly | 604800   | 52          | http:client-volume | 143
507340800 | yearly | 604800   | 52          | http:client-volume | 161
507340800 | yearly | 604800   | 52          | http:client-volume | 175

写一个xsl代码片段怎么样?这是我想出的一个,运行时使用:xsltproc MY_XSL_FILE YOUR_XML_FILE

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:s="http://exslt.org/strings"
  version="1.0">
  <xsl:output method="text"/>
  <xsl:template match="text()"/>
  <xsl:template match="TIME-SERIES">
    <xsl:variable name="last-update-time" select="@last-update-time"/>
    <xsl:variable name="name" select="@name"/>
    <xsl:variable name="sample-interval" select="@sample-interval"/>
    <xsl:variable name="observations" select="@observations"/>
    <xsl:variable name="parent" select="@parent"/>
    <!-- heading -->
    <xsl:text>date      | name   | interval | observation | parent             | value&#0010;</xsl:text>
    <xsl:for-each select="s:tokenize(text(), ' ')">
      <xsl:value-of select="$last-update-time"/>
      <xsl:text> | </xsl:text>
      <xsl:value-of select="$name"/>
      <xsl:text> | </xsl:text>
      <xsl:value-of select="$sample-interval"/>
      <xsl:text>  | </xsl:text>
      <xsl:value-of select="$observations"/>
      <xsl:text>           | </xsl:text>
      <xsl:value-of select="$parent"/>
      <xsl:text> | </xsl:text>
      <xsl:value-of select="."/>
      <xsl:text>&#0010;</xsl:text>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

最新更新