I have a problem, consider the following 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 have to work with SSIS. I would like to get all data 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: @*[name() = 'EngineID'] | @*[name() = 'OrderID'] | child::node()/@*[name() = 'InstID'] | child::node()/@*[name() = 'SeqID']
How can I get the OtherInfo data in such a way, that it would always give back something, even if the node does not exist? Example, if the node does not exist, give back "No".
On the discussion side, I need this, because the SSIS mapping use integer indexing on the result set. If the result set can be 4 or 5 long, I get index out of bounds error. This is my idea to circumvent the problem, to always return a fixed length result set.
If this can't be done, the other idea would be to expand the XML with default values. So in case the other question is: Can you show me, how to add default values to an XML with XPATH? Example: Make the mentioned XML to this:
<?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" OtherInfo="defaultvalue"><INSTSPECIFIER InstID="29" SeqID="19"/></ORDER>
</APIDATA>
Or is there a more elegant way of solving this in SSIS?