SSIS 中不同长度的 XML 索引 [英] XML indexing in SSIS with different length

查看:22
本文介绍了SSIS 中不同长度的 XML 索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 XML:

<?xml version="1.0" encoding="UTF-16"?>
<APIDATA xmlns="api-com">
<ORDER EngineID="1" OrderID="66" OtherInfo="yes"><INSTSPECIFIER InstID="27" SeqID="17"/></ORDER>
<ORDER EngineID="2" OrderID="67" OtherInfo="yes"><INSTSPECIFIER InstID="28" SeqID="18"/></ORDER>
<ORDER EngineID="3" OrderID="68"><INSTSPECIFIER InstID="29" SeqID="19"/></ORDER>
</APIDATA>

我想在所有订单条目的每个循环中获取 SSIS 变量的所有 ID.到目前为止,我可以在 SSIS 的控制流中使用 ForeachLoop 获取数据,如下所示:

I would like to get all IDs to SSIS variables in a for each loop for all Order entries. So far I can get data with a ForeachLoop in control flow in SSIS, with the following:

EnumerationType:  ElementCollection
OuterXPathString: //*[name() = 'ORDER']
InnerElementType: NodeText
InnerXPathString: @* | child::node()/@*

然后在变量映射上,我遇到了问题,即 XML 的行长度不同.例如:第三行没有其他信息条目.如果我将变量映射到索引 4,这会导致循环出错.

Then on variable mappings I come accross the problem, that the lines of the XML are not the same length. E.g.: the third line does not have an OtherInfo entry. This causes the loop to die with error if I map a variable to index 4.

这个问题的解决方案是什么?

What is the solution to this problem?

感谢您的帮助.

推荐答案

这次使用 @*[name() = 'EngineID'] |@*[name() = '订单ID'] |child::node()/@*[name() = 'InstID'] |child::node()/@*[name() = 'SeqID'] 作为 InnerXPathString.

This time use @*[name() = 'EngineID'] | @*[name() = 'OrderID'] | child::node()/@*[name() = 'InstID'] | child::node()/@*[name() = 'SeqID'] as InnerXPathString.

这篇关于SSIS 中不同长度的 XML 索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆