Here we go...another XML question :) I was under the impression that

Here we go...another XML question :)

I was under the impression that using this type of syntax would check to see if a tag exists however, it's really only checking to see if there is any value in an existing tag.

if( (xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='ProductTypeCode']/text()")) = "", "", xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='ProductTypeCode']/text()") )

What I need to do is determine if a child tag exists or not. If it exists, I want to take the value. If it doesn't, I don't want to store an empty string value in the CDT equivalent field.

Any ideas how the syntax would look for that?...

OriginalPostID-60871

OriginalPostID-60871

  Discussion posts and replies are publicly visible

Parents
  • No luck....no value is being stored in the test boolean. I cut/paste right from the forum. For the account I am using, there are 0 instances of ProductTypeCode so I left the [1]. The application will be looking for multiple instances of ProductTypeCode...it is in a child object <Account> that can repeat any number of times. I want to save the <ProductTypeCode> value when the tag exists and when the tag doesn't exist, I want to save an empy string. All of this will go into a multple PV array.

    aTempAccount_Ary

    CustomerID
    AccountID
    ProductTypeCode


    XML Response Structure
    <GetCustomerAccountsResponse>
    <GetCustomerAccountsResponseMessage>
    <Customer>
    <Accounts>
    <Account>
    <ProductTypeCode>
    </Account>
    <Account>
    **missing ProductTypeCode tag
    </Account>
    <Account>
    <ProductTypeCode>
    </Account>
    </Accounts>
    </Customer>
    </GetCustomerAccountsResponseMessage>
    </GetCustomerAccountsResponse>
Reply
  • No luck....no value is being stored in the test boolean. I cut/paste right from the forum. For the account I am using, there are 0 instances of ProductTypeCode so I left the [1]. The application will be looking for multiple instances of ProductTypeCode...it is in a child object <Account> that can repeat any number of times. I want to save the <ProductTypeCode> value when the tag exists and when the tag doesn't exist, I want to save an empy string. All of this will go into a multple PV array.

    aTempAccount_Ary

    CustomerID
    AccountID
    ProductTypeCode


    XML Response Structure
    <GetCustomerAccountsResponse>
    <GetCustomerAccountsResponseMessage>
    <Customer>
    <Accounts>
    <Account>
    <ProductTypeCode>
    </Account>
    <Account>
    **missing ProductTypeCode tag
    </Account>
    <Account>
    <ProductTypeCode>
    </Account>
    </Accounts>
    </Customer>
    </GetCustomerAccountsResponseMessage>
    </GetCustomerAccountsResponse>
Children
No Data