Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8487643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:18:19+00:00 2026-06-10T21:18:19+00:00

I have a problem, consider the following XML: <?xml version=1.0 encoding=UTF-16?> <APIDATA xmlns=api-com> <ORDER

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:18:21+00:00Added an answer on June 10, 2026 at 9:18 pm

    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”.

    Here is one way to produce the value of the OtherInfo attribute if this attribute exists or the string "no" otherwise:

          concat(@OtherInfo,
                 substring('no',1 + 2*boolean(@OtherInfo)))
    

    When this Xpath 1.0 expression is evaluated on the following element:

        <ORDER EngineID="1" OrderID="66" OtherInfo="yes">
                <INSTSPECIFIER InstID="27" SeqID="17"/>
    

    the result is:

    yes
    

    But when the same expression is evaluated on:

        <ORDER EngineID="3" OrderID="68">
                <INSTSPECIFIER InstID="29" SeqID="19"/>
    

    then the result is:

    no
    

    XSLT-based verification:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="/*/*">
             <xsl:value-of select=
             "concat(@OtherInfo,
                     substring('no',1 + 2*boolean(@OtherInfo)))
             "/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document:

    <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>
    

    The Xpath expression is evaluated against each ORDER element and the result of the evaluation is copied to the output:

    yesyesno
    

    Explanation:

    The expression:

          concat(@OtherInfo,
                 substring('no',1 + 2*boolean(@OtherInfo)))
    

    produces the concatenation of two strings.

    In case the context node has an attribute named OtherInfo, then the second string is the empty string and only the first string (the value of the attribute) is produced.

    In case the context node has no attribute named OtherInfo, then the first argument of concat() is the empty string and the second argument is evaluated and output.

    How is this subexpression evaluated in each of these two cases:

    substring('no',1 + 2*boolean(@OtherInfo))
    
    1. If @OtherInfo exists. Then 2*boolean(@OtherInfo) = 2*true() = 2*1 = 2 Therefore, the expression is equivalent to: substring('no',3) and this is the empty string, because "no" has a length of only 2.

    2. If @OtherInfo doesn’t exist. Then 2*boolean(@OtherInfo) = 2*false() = 2*0 = 0. Therefore, the expression is equivalent to: substring('no',1) and this evaluates to the string "no".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file of the following structure: <?xml version=1.0 encoding=utf-8?> <root> <ArrayOfLocationDTO
Propose to consider the following problem. Suppose we have some composite object. Are there
I have a problem with Visual Studio 2008 concerning virtual inheritance. Consider the following
Consider the following security problem: I have a static base path ( /home/username/ )
I have the following problem: Let's consider we have #define SET callMe #define COLUMN(x)
I'm writing some Boost.Preprocessor metaprogram, and I have the following problem. Consider the following
Consider the following problem: We have two sequences of cargo loads which can contain
I have encountered a slightly unusual problem. Consider the following code: class parser {
Consider the following problem: You have a class 'A' that serves as a base
I've got a problem with the following, let's consider this XML document : <FEATURE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.