SSIS中的XML索引具有不同的长度

时间:2022-12-13 16:34:27

I have the following 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>

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:

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

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

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.

然后在变量映射中遇到问题,XML的行长度不同。例如:第三行没有OtherInfo条目。如果我将变量映射到索引4,这会导致循环死错。

What is the solution to this problem?

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

Thanks for the help.

谢谢您的帮助。

1 个解决方案

#1


1  

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

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

#1


1  

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

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